authentication_login_form

The authentication_login_form tag renders a form that allows the visitor to login as a certain Authentication Type.

The authentication_login_form tag takes the plural name of an Authentication Type as input. 

It is also possible to give extra arguments as a key,value pair. These arguments are transformed into html attributes on the generated form html tag.

The authentication_login_form tag requires that the authentication_field tag is called inside of it for each of the inputs:

  • 'email'

  • 'password'

Accepts parameter redirect_to, with a path that the user is redirected to after successful login.

Also accepts a parameter error_msg to use a custom message when logging in does not work, for example when the wrong credentials are used. Message is returned in request.flash object.

Example:

{% authentication_login_form "dealers", error_msg: "custom error message", redirect_to: "/portal-page" %}     {% authentication_field "email", class: "form-field" %}     {% authentication_field "password", class: "form-field" %}     <input type="submit" value="Login!"> {% endauthentication_login_form %}

Note: Do not forget to display the output of [request.flash], since that contains potential error messages.

JSON endpoint

Also accepts parameter output_as, which currently only accepts "json" as value. If this parameter is set, no html is returned, but everything needed for the payload in authentication endpoints is returned in JSON format. With this you can call the following endpoint in order to login through a JSON request:

POST /:authentication_type_name/login Accept: application/json { "authentication_object": { "email": "test@test.nl", "password": "Pa55word", ... # JSON output from tag } }