Phauxth v0.15.0 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 two options:

  • max_age - the length of the validity of the token

    • the default is two weeks
  • user_context - the user context module to be used

    • the default is MyApp.Accounts

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 token as a remember me cookie

Delete the remember_me cookie

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

Link to this function add_rem_cookie(conn, user_id, max_age \\ 1209600) View Source

Add a token as a remember me cookie.

Delete the remember_me cookie.

Get the user based on the session id or token id.

This function also calls the database to get user information.

Link to this function get_user(conn, token, arg) View Source

Log the result of the authentication and return the user struct or nil.

Set the current_user variable.