Class: Aker::Form::Middleware::LoginResponder

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

Overview

Rack middleware used by Aker::Form::Mode that finishes login requests by rendering a "Login successful" message.

This middleware implements half of the form login process. The other half is implemented by LoginRenderer.

Author:

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Rack::ConfigurationHelper

#using_custom_login_page?, #using_custom_logout_page?

Methods included from Rack::EnvironmentHelper

#authority, #configuration, #interactive?

Methods included from LoginFormAssetProvider

#asset_root, #login_css, #login_html

Constructor Details

- (LoginResponder) initialize(app, login_path)

Instantiates the middleware.

Parameters:

  • app (Rack app)

    the Rack application on which this middleware should be layered

  • login_path (String)

    the login path



27
28
29
30
# File 'lib/aker/form/middleware/login_responder.rb', line 27

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

Instance Attribute Details

- (String) login_path

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

Returns:

  • (String)

    the login path



19
20
21
# File 'lib/aker/form/middleware/login_responder.rb', line 19

def 
  @login_path
end

Instance Method Details

- (Object) call(env)

Rack entry point. Responds to POST /login.

If the user is authenticated and a URL is given in the url parameter, then this action will redirect to url.

Parameters:

  • env

    the Rack environment

Returns:

  • a finished Rack response



40
41
42
43
44
45
# File 'lib/aker/form/middleware/login_responder.rb', line 40

def call(env)
  case [env['REQUEST_METHOD'], env['PATH_INFO']]
    when ['POST', ]; respond(env)
    else @app.call(env)
  end
end