Phauxth v2.0.0-rc.0 Phauxth.Remember View Source
Remember me module.
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.
Configuration / setup
Add the user_context
module (the module you are using to handle
user data) to the config:
config :phauxth, user_context: MyApp.Accounts
The user_context module (in this case, MyApp.Accounts) needs to have a
get_by(attrs)
function, which returns either a user struct or nil,
and a create_session(user)
function, which returns {:ok, session}
or
{:error, message}
.
You also need to define a token module that implements the Phauxth.Token behaviour. See the documentation for the Phauxth.Token module for details.
Options
There is one option:
:log_meta
- additional custom metadata for Phauxth.Log- this should be a keyword list
There are also options for verifying the token.
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
Link to this section Functions
Adds a remember me cookie to the conn.
delete_rem_cookie(Plug.Conn.t()) :: Plug.Conn.t()
Deletes the remember_me cookie from the conn.