Phauxth v2.0.0-alpha.2 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.

Options

There are three options:

  • :user_context - the users module to be used when querying the database

    • the default is Phauxth.Config.user_context()
  • :session_id_func - the function used to set the session id

    • the default is &Phauxth.Utils.uuid4/0
  • :max_age - the length of the validity of the cookie / token

    • the default is one week
  • :log_meta - additional custom metadata for Phauxth.Log

    • this should be a keyword list

In addition, there are also options for generating 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

Functions

Adds a remember me cookie to the conn

Deletes the remember_me cookie from the conn

Gets the user data from the token

Link to this section Functions

Link to this function add_rem_cookie(conn, user_id, max_age \\ 604800) View Source
add_rem_cookie(Plug.Conn.t(), integer(), integer()) :: Plug.Conn.t()

Adds a remember me cookie to the conn.

Link to this function delete_rem_cookie(conn) View Source
delete_rem_cookie(Plug.Conn.t()) :: Plug.Conn.t()

Deletes the remember_me cookie from the conn.

Link to this function get_user_data(token_mod, token, arg) View Source
get_user_data(Plug.Conn.t(), String.t(), tuple()) :: map() | nil

Gets the user data from the token.