class LobbyBoy::OmniAuth::FailureEndpoint
This is a copy of the default OmniAuth
FailureEndpoint
minus the raise_out! we don't want and plus the actual error message as opposed to always just 'missing_code'.
Also when authentication with prompt=none fails it will retry with prompt=login.
Attributes
env[R]
Public Class Methods
call(env)
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 11 def self.call(env) new(env).call end
new(env)
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 15 def initialize(env) @env = env end
Public Instance Methods
call()
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 19 def call if script? redirect_to '/session/state?state=unauthenticated' elsif retry? retry_interactive else redirect_to_failure end end
error()
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 37 def error env['omniauth.error'] || ::OmniAuth::Error.new(env['omniauth.error.type']) end
message_query_param(message)
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 81 def message_query_param(message) 'message=' + escape(message) end
omniauth_path()
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 73 def omniauth_path script_name + ::OmniAuth.config.path_prefix end
origin()
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 93 def origin env['omniauth.origin'] end
origin_query_param()
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 97 def origin_query_param 'origin=' + escape(origin) if origin end
params()
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 29 def params request.params end
redirect_to_failure()
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 61 def redirect_to_failure params = [ message_query_param(error.message), origin_query_param, strategy_name_query_param ] url = omniauth_path + '/failure?' + params.compact.join('&') redirect_to url end
request()
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 33 def request @request ||= ::Rack::Request.new env end
retry?()
click to toggle source
Authentication with &prompt=none fails if the user is not already signed in with the respective provider. Retry without &prompt=none in that case.
Google responds with 'immediate_failed' in that case. Our own concierge with 'interaction_required'.
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 51 def retry? ['immediate_failed', 'interaction_required'].include? error.message end
retry_interactive()
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 55 def retry_interactive url = "#{omniauth_path}/#{strategy.name}?#{origin_query_param}&prompt=login" redirect_to url end
script?()
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 41 def script? origin =~ /#{script_name}\/session\/state/ end
script_name()
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 77 def script_name env['SCRIPT_NAME'] end
strategy()
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 89 def strategy env['omniauth.error.strategy'] end
strategy_name_query_param()
click to toggle source
# File lib/lobby_boy/omni_auth/failure_endpoint.rb, line 85 def strategy_name_query_param 'strategy=' + escape(strategy.name) if strategy end