Haytni.RecoverablePlugin (Haytni v0.7.0) View Source
This plugin allows the user to reset its password if he forgot it. To do so, its email addresse (default) is asked to him then an unique token is generated and send to its mailbox. This mail contains a link to activate where a new password will be requested to override the previous one.
Fields: none
Configuration:
reset_password_within
(default:{6, :hour}
): the delay before the token expiresreset_password_keys
(default:[:email]
): the field(s) to be matched to send a reinitialization tokenstack Haytni.RecoverablePlugin, reset_password_keys: [:email], reset_password_within: {6, :hour}
Routes:
haytni_<scope>_password_path
(actions: new/create, edit/update): default path is"/password"
but you can customize it to whatever you want by specifying the option:password_path
to your YourApp.Haytni.routes/1 call in your router (eg:YourApp.Haytni.routes(password_path: "/recover")
)
Link to this section Summary
Functions
Callback implementation for Haytni.Plugin.fields/1
.
Callback implementation for Haytni.Plugin.find_user/3
.
Callback implementation for Haytni.Plugin.invalid?/3
.
The translated string to display when a password recovery token is invalid (ie not associated to someone)
The (database) attributes as a keyword-list to redefine the password (after hashing) and void previous password recovery token
Callback implementation for Haytni.Plugin.on_delete_user/4
.
Callback implementation for Haytni.Plugin.on_email_change/4
.
Callback implementation for Haytni.Plugin.on_failed_authentication/5
.
Callback implementation for Haytni.Plugin.on_logout/3
.
Callback implementation for Haytni.Plugin.on_registration/3
.
Callback implementation for Haytni.Plugin.on_successful_authentication/6
.
Change user's password from its recovering token.
Converts the parameters received by the controller from which users can start the password recovery procedure by requesting a
recovery token into an %Ecto.Changeset{}
.
Send instructions to reset user's password.
Callback implementation for Haytni.Plugin.validate_create_registration/3
.
Callback implementation for Haytni.Plugin.validate_password/3
.
Callback implementation for Haytni.Plugin.validate_update_registration/3
.
Link to this section Functions
Callback implementation for Haytni.Plugin.fields/1
.
Callback implementation for Haytni.Plugin.find_user/3
.
Callback implementation for Haytni.Plugin.invalid?/3
.
Specs
invalid_token_message() :: String.t()
The translated string to display when a password recovery token is invalid (ie not associated to someone)
Specs
The (database) attributes as a keyword-list to redefine the password (after hashing) and void previous password recovery token
Callback implementation for Haytni.Plugin.on_delete_user/4
.
Callback implementation for Haytni.Plugin.on_email_change/4
.
Callback implementation for Haytni.Plugin.on_failed_authentication/5
.
Callback implementation for Haytni.Plugin.on_logout/3
.
Callback implementation for Haytni.Plugin.on_registration/3
.
on_successful_authentication(conn, user, multi, keywords, module, config)
View SourceCallback implementation for Haytni.Plugin.on_successful_authentication/6
.
Specs
recover( module :: module(), config :: Haytni.RecoverablePlugin.Config.t(), password_params :: %{required(String.t()) => String.t()} ) :: {:ok, Haytni.user() | nil} | {:error, Ecto.Changeset.t()}
Change user's password from its recovering token.
Returns {:ok, user}
if successful else {:error, changeset}
when the token:
- is empty
- doesn't exist
- is expired
Specs
recovering_changeset( config :: Haytni.RecoverablePlugin.Config.t(), request_params :: Haytni.params() ) :: Ecto.Changeset.t()
Converts the parameters received by the controller from which users can start the password recovery procedure by requesting a
recovery token into an %Ecto.Changeset{}
.
Specs
send_reset_password_instructions( module :: module(), config :: Haytni.RecoverablePlugin.Config.t(), request_params :: Haytni.params() ) :: {:ok, Haytni.Token.t() | nil} | {:error, Ecto.Changeset.t()}
Send instructions to reset user's password.
Returns:
{:error, changeset}
if fields (form) were not filled{:ok, nil}
if there is no account matchingconfig.reset_password_keys
{:ok, token}
if successful
Callback implementation for Haytni.Plugin.validate_create_registration/3
.
Callback implementation for Haytni.Plugin.validate_password/3
.
Callback implementation for Haytni.Plugin.validate_update_registration/3
.