Pow v0.1.0-alpha.1 Pow.Plug.Base behaviour View Source

This plug macro will set the :pow_config key, 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

  def fetch(conn, _config) do
    user = fetch_user_from_cookie(conn)

    {conn, user}
  end

  def create(conn, user, _config) do
    conn = update_cookie(conn, user)

    {conn, user}
  end

  def delete(conn, _config) do
    delete_cookie(conn)
  end
end

Link to this section Summary

Link to this section Callbacks

Link to this callback create(arg0, map, arg2) View Source
create(Plug.Conn.t(), map(), Pow.Config.t()) :: {Plug.Conn.t(), map()}
Link to this callback fetch(arg0, arg1) View Source
fetch(Plug.Conn.t(), Pow.Config.t()) :: {Plug.Conn.t(), map() | nil}