Class: LobbyBoy::OmniAuth::FailureEndpoint
- Inherits:
-
Object
- Object
- LobbyBoy::OmniAuth::FailureEndpoint
- Includes:
- Functions
- Defined in:
- lib/lobby_boy/omni_auth/failure_endpoint.rb
Overview
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.
Defined Under Namespace
Modules: Functions
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #error ⇒ Object
-
#initialize(env) ⇒ FailureEndpoint
constructor
A new instance of FailureEndpoint.
- #message_query_param(message) ⇒ Object
- #omniauth_path ⇒ Object
- #origin ⇒ Object
- #origin_query_param ⇒ Object
- #params ⇒ Object
- #redirect_to_failure ⇒ Object
- #request ⇒ Object
-
#retry? ⇒ Boolean
Authentication with &prompt=none fails if the user is not already signed in with the respective provider.
- #retry_interactive ⇒ Object
- #script? ⇒ Boolean
- #script_name ⇒ Object
- #strategy ⇒ Object
- #strategy_name_query_param ⇒ Object
Methods included from Functions
Constructor Details
#initialize(env) ⇒ FailureEndpoint
Returns a new instance of FailureEndpoint.
15 16 17 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 15 def initialize(env) @env = env end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
9 10 11 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 9 def env @env end |
Class Method Details
.call(env) ⇒ Object
11 12 13 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 11 def self.call(env) new(env).call end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 |
# 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 ⇒ Object
37 38 39 |
# 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) ⇒ Object
81 82 83 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 81 def () 'message=' + escape() end |
#omniauth_path ⇒ Object
73 74 75 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 73 def omniauth_path script_name + ::OmniAuth.config.path_prefix end |
#origin ⇒ Object
93 94 95 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 93 def origin env['omniauth.origin'] end |
#origin_query_param ⇒ Object
97 98 99 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 97 def origin_query_param 'origin=' + escape(origin) if origin end |
#params ⇒ Object
29 30 31 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 29 def params request.params end |
#redirect_to_failure ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 61 def redirect_to_failure params = [ (error.), origin_query_param, strategy_name_query_param ] url = omniauth_path + '/failure?' + params.compact.join('&') redirect_to url end |
#request ⇒ Object
33 34 35 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 33 def request @request ||= ::Rack::Request.new env end |
#retry? ⇒ Boolean
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’.
51 52 53 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 51 def retry? ['immediate_failed', 'interaction_required'].include? error. end |
#retry_interactive ⇒ Object
55 56 57 58 59 |
# 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? ⇒ Boolean
41 42 43 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 41 def script? origin =~ /#{script_name}\/session\/state/ end |
#script_name ⇒ Object
77 78 79 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 77 def script_name env['SCRIPT_NAME'] end |
#strategy ⇒ Object
89 90 91 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 89 def strategy env['omniauth.error.strategy'] end |
#strategy_name_query_param ⇒ Object
85 86 87 |
# File 'lib/lobby_boy/omni_auth/failure_endpoint.rb', line 85 def strategy_name_query_param 'strategy=' + escape(strategy.name) if strategy end |