Pow v1.0.15 Pow.Plug 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.

Clears the user authentication from the session.

Creates a new user.

Get the current user assigned to the conn.

Get the current user assigned to 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.

Updates the current authenticated user.

Link to this section Functions

Link to this function

assign_current_user(conn, user, config)

View Source
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.

Link to this function

authenticate_user(conn, params)

View Source
authenticate_user(Plug.Conn.t(), map()) :: {:ok | :error, Plug.Conn.t()}

Authenticates a user.

If successful, a new session will be created.

Link to this function

change_user(conn, params \\ %{})

View Source
change_user(Plug.Conn.t(), map()) :: map()

Creates a changeset from the current authenticated user.

Link to this function

clear_authenticated_user(conn)

View Source
clear_authenticated_user(Plug.Conn.t()) :: {:ok, Plug.Conn.t()}

Clears the user authentication from the session.

Link to this function

create_user(conn, params)

View Source
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.

Link to this function

current_user(conn)

View Source
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.

Link to this function

current_user(map, config)

View Source
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.

Link to this function

delete_user(conn)

View Source
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.

Link to this function

fetch_config(map)

View Source
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.

Link to this function

get_plug(config)

View Source
get_plug(Pow.Config.t()) :: atom()
Link to this function

prepend_with_namespace(config, string)

View Source
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.

Link to this function

put_config(conn, config)

View Source
put_config(Plug.Conn.t(), Pow.Config.t()) :: Plug.Conn.t()

Put the provided config as a private key in the connection.

Link to this function

update_user(conn, params)

View Source
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.