Phauxth v1.0.3 Phauxth.Confirm View Source
Module to provide user confirmation for new users and when resetting passwords.
Link to this section Summary
Functions
Verify the confirmation key and get the user data from the database
Link to this section Functions
Verify the confirmation key and get the user data from the database.
This can be used to confirm an email for new users and also for password resetting.
Options
There are three options for the verify function:
max_age - the maximum age of the token, in seconds
- the default is 1200 seconds (20 minutes)
mode - the mode - email confirmation or password resetting
- set this to :pass_reset to use this function for password resetting
log_meta - additional custom metadata for Phauxth.Log
- this should be a keyword list
Examples
The following function is an example of using verify in a Phoenix controller.
def index(conn, params) do
case Phauxth.Confirm.verify(params, Accounts) do
{:ok, user} ->
Accounts.confirm_user(user)
Message.confirm_success(user.email)
conn
|> put_flash(:info, "Your account has been confirmed")
|> redirect(to: session_path(conn, :new))
{:error, message} ->
conn
|> put_flash(:error, message)
|> redirect(to: session_path(conn, :new))
|> halt
end
end
In this example, the Accounts.confirm_user
function updates the
database, setting the confirmed_at
value to the current time.