Phauxth v1.2.3 Phauxth.Remember View Source
Remember me module.
Calling Phauxth.Remember with plug checks for a remember_me
cookie,
which contains a token. The token is then checked, and if it is valid,
the user is added to the session.
This module also contains functions to add / delete the remember_me
cookie.
Options
There are three options:
:max_age
- the length of the validity of the cookie / token- the default is one week
:user_context
- the user context module to be used- the default is MyApp.Accounts
:log_meta
- additional custom metadata for Phauxth.Log- this should be a keyword list
In addition, there are also options for generating the token. See the documentation for the Phauxth.Token module for details.
Examples
Add the following line to the pipeline you want to authenticate in
the web/router.ex
file:
plug Phauxth.Authenticate
plug Phauxth.Remember
Make sure you add the Phauxth.Remember Plug after Phauxth.Authenticate.
Link to this section Summary
Functions
Add a remember me cookie to the conn
Check the session for the current user
Check the token for the current user
Delete the remember_me cookie from the conn
Checks to see if the session is fresh - newly logged in
Get the user based on the session id or token id
Log the result of the authentication and return the user struct or nil
Set the current_user
variable
Link to this section Functions
Add a remember me cookie to the conn.
Check the session for the current user.
Check the token for the current user.
Delete the remember_me cookie from the conn.
Checks to see if the session is fresh - newly logged in.
Get the user based on the session id or token id.
This function also calls the database to get user information.
Log the result of the authentication and return the user struct or nil.
Set the current_user
variable.