Class: Aker::Form::CustomViewsMode
- Inherits:
-
Mode
- Object
- Warden::Strategies::Base
- Modes::Base
- Mode
- Aker::Form::CustomViewsMode
- Defined in:
- lib/aker/form/custom_views_mode.rb
Overview
A specialization of the :form mode which allows the Aker-using application to provide the login and logout views.
If you use this mode, your application is responsible for
rendering appropriate views in response to GET to the login and
logout paths. By default, the login and logout paths are /login
and /logout (relative to your application). If your application
uses other paths, you can change these to match via configuration
parameters; see the example below.
The login view may receive with one or more query parameters, depending on how the user is directed to it:
url: If the user is redirected to the login page after attempting to access a protected resource, the URL to the resource she was attempting to access will be passed asurlin the query string.session_expired: If the user is redirected to the login page because she made a request after her session expired,session_expired=truewill be in the query string.
The login view should arrange for the user's username and password
to be POSTed to the login path using parameters with those
names.
If the form is being re-rendered because the user's credentials were rejected, the following variables will be available in the rack environment:
aker.form.login_failed:trueaker.form.username: the attempted username, if any
In addition to re-rendering the form, It is the responsibility of the custom view to send the appropriate HTTP status (401) in this case.
If the POST is successful, the user will be redirected to the
originally requested URL (so long as it is still passed along in
the url parameter). If there was no originally requested
URL, the user will be redirected to the root of the application.
The logout view may do whatever your application deems appropriate. If you don't provide a custom logout view, you will get the very spare default.
Class Method Summary collapse
-
.append_middleware(builder) ⇒ void
Override parent to append only Middleware::CustomViewLoginResponder.
-
.key ⇒ :custom_form
The configuration key for this mode.
-
.prepend_middleware(builder) ⇒ void
Override parent to prepend nothing.
Methods inherited from Mode
#credentials, #kind, #login_url, #on_ui_failure, #valid?
Methods included from Modes::Support::AttemptedPath
Methods inherited from Modes::Base
#authenticate!, #authority, #configuration, #interactive?, #store?
Methods included from Rack::EnvironmentHelper
#authority, #configuration, #interactive?
Class Method Details
.append_middleware(builder) ⇒ void
This method returns an undefined value.
Override parent to append only Middleware::CustomViewLoginResponder.
75 76 77 |
# File 'lib/aker/form/custom_views_mode.rb', line 75 def append_middleware(builder) builder.use Middleware::CustomViewLoginResponder end |
.key ⇒ :custom_form
The configuration key for this mode.
62 63 64 |
# File 'lib/aker/form/custom_views_mode.rb', line 62 def key :custom_form end |
.prepend_middleware(builder) ⇒ void
This method returns an undefined value.
Override parent to prepend nothing.
69 70 |
# File 'lib/aker/form/custom_views_mode.rb', line 69 def prepend_middleware(builder) end |