Class: Aker::Rack::DefaultLogoutResponder

Inherits:
Object
  • Object
show all
Includes:
ConfigurationHelper
Defined in:
lib/aker/rack/default_logout_responder.rb

Overview

Provides a default response for GET of the application's configured logout path.

Instance Method Summary collapse

Methods included from ConfigurationHelper

#login_path, #logout_path

Methods included from EnvironmentHelper

#authority, #configuration, #interactive?

Constructor Details

#initialize(app) ⇒ DefaultLogoutResponder

Instantiates the middleware.

Parameters:

  • app (Rack app)

    the Rack application on which this middleware should be layered



15
16
17
# File 'lib/aker/rack/default_logout_responder.rb', line 15

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

When the path is the configured logout path, renders a logout response.

Parameters:

  • env (Hash)

    a Rack environment



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/aker/rack/default_logout_responder.rb', line 24

def call(env)
  result = @app.call(env)

  if result.first == 404 &&
      env['REQUEST_METHOD'] == 'GET' &&
      env['PATH_INFO'] == logout_path(env)
    ::Rack::Response.new('You have been logged out.', 200).finish
  else
    result
  end
end