Class: Aker::Form::Middleware::LoginRenderer
- Inherits:
-
Object
- Object
- Aker::Form::Middleware::LoginRenderer
- 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.
Instance Attribute Summary (collapse)
-
- (String) login_path
The path at which the middleware will watch for login requests.
Instance Method Summary (collapse)
-
- (Object) call(env)
Rack entry point.
-
- (LoginRenderer) initialize(app, login_path)
constructor
Instantiates the middleware.
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.
27 28 29 30 |
# File 'lib/aker/form/middleware/login_renderer.rb', line 27 def initialize(app, login_path) @app = app self.login_path = login_path end |
Instance Attribute Details
- (String) login_path
The path at which the middleware will watch for login requests.
19 20 21 |
# File 'lib/aker/form/middleware/login_renderer.rb', line 19 def login_path @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_pageis truthy,callpasses the request down through the Rack stack. - If the method is GET and the path is
login_path,callreturns an HTML form for submitting a username and password. - If the method is GET and the path is
login_path + "/login.css",callreturns the CSS for the aforementioned form. - Otherwise,
callpasses the request down through the Rack stack.
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 using_custom_login_page?(env) case [env['REQUEST_METHOD'], env['PATH_INFO']] when ['GET', login_path]; provide_login_html(env) when ['GET', login_path + '/login.css']; provide_login_css else @app.call(env) end end |