Class: Aker::Form::Middleware::LogoutResponder

Inherits:
Object
  • Object
show all
Includes:
LoginFormAssetProvider, Rack::ConfigurationHelper
Defined in:
lib/aker/form/middleware/logout_responder.rb

Instance Method Summary collapse

Methods included from Rack::ConfigurationHelper

#login_path, #logout_path

Methods included from Rack::EnvironmentHelper

#authority, #configuration, #interactive?

Methods included from LoginFormAssetProvider

#asset_root, #login_css, #login_html

Constructor Details

#initialize(app) ⇒ LogoutResponder

Returns a new instance of LogoutResponder



8
9
10
# File 'lib/aker/form/middleware/logout_responder.rb', line 8

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

When given GET to the configured logout path, builds a Rack response containing the login form with a "you have been logged out" notification. Otherwise, passes the response on.

Returns:

  • a finished Rack response



18
19
20
21
22
23
24
25
26
# File 'lib/aker/form/middleware/logout_responder.rb', line 18

def call(env)
  if env['REQUEST_METHOD'] == 'GET' && env['PATH_INFO'] == logout_path(env)
    ::Rack::Response.new((env, :logged_out => true)) do |resp|
      resp['Content-Type'] = 'text/html'
    end.finish
  else
    @app.call(env)
  end
end