Class: Aker::Form::Middleware::LoginRenderer

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

Overview

Rack middleware used by Aker::Form::Mode to render an HTML login form.

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

Author:

  • David Yip

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) ⇒ LoginRenderer

Instantiates the middleware.



23
24
25
# File 'lib/aker/form/middleware/login_renderer.rb', line 23

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Rack entry point.

call returns one of three responses, depending on the path and method.

  • If the method is GET and the path is login_path, call returns an HTML form for submitting a username and password.
  • If the method is GET and the path is login_path + "/login.css", call returns the CSS for the aforementioned form.
  • Otherwise, call passes the request down through the Rack stack.


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

def call(env)
  case [env['REQUEST_METHOD'], env['PATH_INFO']]
    when ['GET', (env)];                (env)
    when ['GET', (env) + '/login.css']; 
    else                                          @app.call(env)
  end
end