authentication_edit_form
Create form
The authentication_edit_form
tag renders a form that allows the visitor logged in as a certain Authentication Type to edit his data, like his email or password.
The authentication_edit_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_edit_form
tag requires that the authentication_field
tag is called inside of it for each of the inputs:
email
current_password
password
confirm_password
Accepts a parameter error_msg
to use a custom message when editing the user does not work, for example when the wrong credentials are used. Message is returned in request.flash object.
Example:
Note: Do not forget to display the output of request.flash, since that contains potential error messages.
Reconfirmation email
When this form created by this tag is submitted successfully, and the email field has changed, 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:
/mails/authentication/[authentication_type_plural_name]/reconfirm_email.plate
In this file you have access to the following variables:
[authentication_type_single_name], e.g. dealer
: The authentication object that was updated through the form. This would return it’s email, for example:dealer.email
.confirm_url
: The url that the user can use to her new email address.
Note: It is required that the confirm_url
variable is used in the template, otherwise the user will never be able to confirm their new email.
submitted_form_fields object
Inside the 'authentication_edit_form
' block, you have access to the submitted_form_fields object. This is a liquid object, representing all the fields that were submitted. This allows you to keep your form fields filled when a validation error occurred.
For example, you can use this object when rendering a form field, as follows:
submitted_form_fields
object, this input field will retain its value when the form is rendered again after a validation error on submitting the form.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 edit the authentication object through a JSON request: