authentication_request_password_recovery_form

The authentication_request_password_recovery_form tag renders a form that allows the visitor that is registered as a certain authentication type to request a new password. E.g. when she forgot her password. When this form is submitted, the visitor will receive a link to recover her password. This will link to the template "recover_password", so make sure that template is implemented.

The authentication_request_password_recovery_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_request_password_recovery_form tag requires that the authentication_field tag is called inside of it for each of the inputs:

  • 'email'

Example:

1 2 3 4 {% authentication_request_password_recovery_form "dealers" %}     {% authentication_field "email", class: "form-field" %}     <input type="submit" value="Update password!"> {% endauthentication_request_password_recovery_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 request a password recovery through a JSON request:

1 2 3 4 5 6 7 8 9 10 11 POST /:authentication_type_name/request_password_recovery Accept: application/json { "authentication_object": { "email": "test@test.nl", "password": "newPa55word", "confirm_password": "newPa55word", ... # JSON output from tag } }

 


When this tag is submitted succesfully, an email will be sent to the submitted email address. It is possible to provide a custom mail template for this in a theme file located at the following path:

1 /mails/authentication/[authentication_type_plural_name]/reset_password.plate

In this file you have access to the following variables:

  • [authentication_type_single_name], e.g. dealer: The authentication object for which the reset was requested through the form. This would return it’s email, for example: dealer.email.

  • reset_url: The url that the user can use to reset her password.

Note: It is required that the 'reset_url' variable is used in the template, otherwise the user will never be able to reset her password