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 Method Summary collapse
-
#call(env) ⇒ Object
Rack entry point.
-
#initialize(app) ⇒ LoginRenderer
constructor
Instantiates the middleware.
Methods included from Rack::ConfigurationHelper
Methods included from Rack::EnvironmentHelper
#authority, #configuration, #interactive?
Methods included from LoginFormAssetProvider
#asset_root, #login_css, #login_html
Constructor Details
#initialize(app) ⇒ LoginRenderer
Instantiates the middleware.
22 23 24 |
# File 'lib/aker/form/middleware/login_renderer.rb', line 22 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.
39 40 41 42 43 44 45 |
# File 'lib/aker/form/middleware/login_renderer.rb', line 39 def call(env) case [env['REQUEST_METHOD'], env['PATH_INFO']] when ['GET', login_path(env)]; provide_login_html(env) when ['GET', login_path(env) + '/login.css']; provide_login_css else @app.call(env) end end |