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

Inherits:
Object
  • Object
show all
Includes:
HtmlResponse, 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:

  • David Yip

Direct Known Subclasses

CustomViewLoginResponder

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

Methods included from HtmlResponse

#html_response

Constructor Details

#initialize(app) ⇒ LoginResponder

Instantiates the middleware.

Parameters:

  • app (Rack app)

    the Rack application on which this middleware should be layered



22
23
24
# File 'lib/aker/form/middleware/login_responder.rb', line 22

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Rack entry point. Responds to a POST to the configured login path.

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



35
36
37
38
39
40
# File 'lib/aker/form/middleware/login_responder.rb', line 35

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