Pow v1.0.17 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.
Any writes to backend store or client should occur in :before_send
callback
as defined in Plug.Conn
. To ensure that the callbacks are called in the
order they were set, a register_before_send/2
method is used to set
callbacks instead of Plug.Conn.register_before_send/2
.
Configuration options
:credentials_cache_store
- the credentials cache store. This value defaults to{Pow.Store.CredentialsCache, backend: Pow.Store.Backend.EtsCache}
. ThePow.Store.Backend.EtsCache
backend store can be changed with the:cache_store_backend
option.:cache_store_backend
- the backend cache store. This value defaults toPow.Store.Backend.EtsCache
.
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 Functions
Link to this section Callbacks
call(arg1, arg2)
View Sourcecall(Plug.Conn.t(), Pow.Config.t()) :: Plug.Conn.t()
create(arg1, map, arg3)
View Sourcecreate(Plug.Conn.t(), map(), Pow.Config.t()) :: {Plug.Conn.t(), map()}
delete(arg1, arg2)
View Sourcedelete(Plug.Conn.t(), Pow.Config.t()) :: Plug.Conn.t()
fetch(arg1, arg2)
View Sourcefetch(Plug.Conn.t(), Pow.Config.t()) :: {Plug.Conn.t(), map() | nil}