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

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

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

- (LoginRenderer) 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_renderer.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_renderer.rb', line 19

def 
  @login_path
end

Instance Method Details

- (Object) call(env)

Rack entry point.

call returns one of four responses, depending on the path, method, and whether or not :use_custom_login_page is set in the :form configuration parameter group.

  • If :use_custom_login_page is truthy, call passes the request down through the Rack stack.
  • 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.

Returns:

  • a finished Rack response



48
49
50
51
52
53
54
55
56
# File 'lib/aker/form/middleware/login_renderer.rb', line 48

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

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