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 /logout.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from ConfigurationHelper

#using_custom_login_page?, #using_custom_logout_page?

Methods included from EnvironmentHelper

#authority, #configuration, #interactive?

Constructor Details

- (DefaultLogoutResponder) initialize(app, logout_path)

Instantiates the middleware.

Parameters:

  • app (Rack app)

    the Rack application on which this middleware should be layered

  • logout_path (String)

    the logout path



21
22
23
24
# File 'lib/aker/rack/default_logout_responder.rb', line 21

def initialize(app, logout_path)
  @app = app
  self.logout_path = logout_path
end

Instance Attribute Details

- (String) logout_path

The path at which the middleware will watch for logout requests.

Returns:

  • (String)

    the logout path



13
14
15
# File 'lib/aker/rack/default_logout_responder.rb', line 13

def logout_path
  @logout_path
end

Instance Method Details

- (Object) call(env)

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

Parameters:

  • env (Hash)

    a Rack environment



30
31
32
33
34
35
36
37
38
# File 'lib/aker/rack/default_logout_responder.rb', line 30

def call(env)
  return @app.call(env) if using_custom_logout_page?(env)

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