Pow.Plug (Pow v1.0.22) View Source
Plug helper methods.
Link to this section Summary
Functions
Assign an authenticated user to the connection.
Authenticates a user.
Creates a changeset from the current authenticated user.
Call create/3 for the Pow plug set for the conn.
Creates a new user.
Get the current user assigned to the conn.
Get the current user assigned to the conn.
Call delete/2 for the Pow plug set for the conn.
Deletes the current authenticated user.
Fetch configuration from the private key in the connection.
Prepend namespace found in Plug Pow configuration to binary.
Put the provided config as a private key in the connection.
Signs a token for public consumption.
Updates the current authenticated user.
Decodes and verifies a token.
Link to this section Functions
Specs
assign_current_user(Plug.Conn.t(), any(), Pow.Config.t()) :: Plug.Conn.t()
Assign an authenticated user to the connection.
This will assign the user to the conn. The key is by default :current_user,
but it can be overridden with :current_user_assigns_key configuration
option.
Specs
authenticate_user(Plug.Conn.t(), map()) :: {:ok | :error, Plug.Conn.t()}
Authenticates a user.
If successful, a new session will be created.
Specs
change_user(Plug.Conn.t(), map()) :: map()
Creates a changeset from the current authenticated user.
Specs
create(Plug.Conn.t(), map()) :: Plug.Conn.t()
Call create/3 for the Pow plug set for the conn.
Specs
create(Plug.Conn.t(), map(), Pow.Config.t()) :: Plug.Conn.t()
Specs
create_user(Plug.Conn.t(), map()) :: {:ok, map(), Plug.Conn.t()} | {:error, map(), Plug.Conn.t()}
Creates a new user.
If successful, a new session will be created.
Specs
current_user(Plug.Conn.t()) :: map() | nil
Get the current user assigned to the conn.
The config is fetched from the conn. See current_user/2 for more.
Specs
current_user(Plug.Conn.t(), Pow.Config.t()) :: map() | nil
Get the current user assigned to the conn.
This will fetch the user from the assigns map in the conn. The key is by
default :current_user, but it can be overridden with
:current_user_assigns_key configuration option.
Specs
delete(Plug.Conn.t()) :: Plug.Conn.t()
Call delete/2 for the Pow plug set for the conn.
Specs
delete(Plug.Conn.t(), Pow.Config.t()) :: Plug.Conn.t()
Specs
delete_user(Plug.Conn.t()) :: {:ok, map(), Plug.Conn.t()} | {:error, map(), Plug.Conn.t()}
Deletes the current authenticated user.
If successful, the user authentication will be cleared from the session.
Specs
fetch_config(Plug.Conn.t()) :: Pow.Config.t()
Fetch configuration from the private key in the connection.
It'll raise an error if configuration hasn't been set as a private key.
Specs
get_plug(Pow.Config.t()) :: atom()
Specs
prepend_with_namespace(Pow.Config.t(), binary()) :: binary()
Prepend namespace found in Plug Pow configuration to binary.
Will prepend :otp_app if exists in configuration.
Specs
put_config(Plug.Conn.t(), Pow.Config.t()) :: Plug.Conn.t()
Put the provided config as a private key in the connection.
Specs
sign_token(Plug.Conn.t(), binary(), binary(), Pow.Config.t() | nil) :: binary()
Signs a token for public consumption.
Used to prevent timing attacks with token lookup.
This uses Pow.Plug.MessageVerifier by default, but can be changed if the
Pow configuration is set with :message_verifier. Pow.Plug.MessageVerifier
can also be configured in this way if :message_verifier is set to
{Pow.Plug.MessageVerifier, key_generator_opts: [length: 64]}
Specs
update_user(Plug.Conn.t(), map()) :: {:ok, map(), Plug.Conn.t()} | {:error, map(), Plug.Conn.t()}
Updates the current authenticated user.
If successful, a new session will be created.
Specs
verify_token(Plug.Conn.t(), binary(), binary(), Pow.Config.t() | nil) :: {:ok, binary()} | :error
Decodes and verifies a token.
Used to prevent timing attacks with token lookup.
This uses Pow.Plug.MessageVerifier by default, but can be changed if the
Pow configuration is set with :message_verifier. Pow.Plug.MessageVerifier
can also be configured in this way if :message_verifier is set to
{Pow.Plug.MessageVerifier, key_generator_opts: [length: 64]}