Class: PublishingPlatform::SSO::FailureApp

Inherits:
ActionController::Metal
  • Object
show all
Includes:
AbstractController::Rendering, ActionController::Redirecting, ActionController::Renderers, ActionController::Rendering, ActionController::UrlFor
Defined in:
lib/publishing_platform_sso/failure_app.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(env) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/publishing_platform_sso/failure_app.rb', line 18

def self.call(env)
  if PublishingPlatform::SSO::ApiAccess.api_call?(env)
    action(:api_invalid_token).call(env)
  elsif PublishingPlatform::SSO::Config.api_only
    action(:api_missing_token).call(env)
  else
    action(:redirect).call(env)
  end
end

Instance Method Details

#api_invalid_tokenObject



33
34
35
# File 'lib/publishing_platform_sso/failure_app.rb', line 33

def api_invalid_token
  api_unauthorized("Bearer token does not appear to be valid", "invalid_token")
end

#api_missing_tokenObject



37
38
39
# File 'lib/publishing_platform_sso/failure_app.rb', line 37

def api_missing_token
  api_unauthorized("No bearer token was provided", "invalid_request")
end

#redirectObject



28
29
30
31
# File 'lib/publishing_platform_sso/failure_app.rb', line 28

def redirect
  store_location!
  redirect_to "/auth/publishing_platform"
end

#store_location!Object

TOTALLY NOT DOING THE SCOPE THING. PROBABLY SHOULD.



47
48
49
# File 'lib/publishing_platform_sso/failure_app.rb', line 47

def store_location!
  session["return_to"] = request.env["warden.options"][:attempted_path] if request.get?
end