Pow v1.0.15 Pow.Plug.Base behaviour View Source

This plug macro will set :pow_config as private, and attempt to fetch and assign a user in the connection if it has not already been assigned. The user will be assigned automatically in any of the operations.

Example

defmodule MyAppWeb.Pow.CustomPlug do
  use Pow.Plug.Base

  @impl true
  def fetch(conn, _config) do
    user = fetch_user_from_cookie(conn)

    {conn, user}
  end

  @impl true
  def create(conn, user, _config) do
    conn = update_cookie(conn, user)

    {conn, user}
  end

  @impl true
  def delete(conn, _config) do
    delete_cookie(conn)
  end
end

Link to this section Summary

Link to this section Callbacks