Class: Aker::Form::CustomViewsMode

  • Object
show all
Defined in:


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 as url in 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=true will 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: true
  • aker.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.


Configuring custom views and custom paths

Aker.configure {
  authority :ldap
  ui_mode :custom_form
  rack_parameters :login_path => '/accts/log-in', :logout_path => '/accts/log-out'

Class Method Summary collapse

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


This method returns an undefined value.

Override parent to append only Middleware::CustomViewLoginResponder.

# File 'lib/aker/form/custom_views_mode.rb', line 75

def append_middleware(builder)
  builder.use Middleware::CustomViewLoginResponder


The configuration key for this mode.


  • (:custom_form)

# File 'lib/aker/form/custom_views_mode.rb', line 62

def key


This method returns an undefined value.

Override parent to prepend nothing.

# File 'lib/aker/form/custom_views_mode.rb', line 69

def prepend_middleware(builder)