View Source PowInvitation.Plug (Pow v1.0.36)

Plug helper functions.

Summary

Functions

Creates a changeset from the user fetched in the connection.

Creates a new invited user by the current user in the connection.

Verifies the signed token and fetches invited user.

Signs the invitation token for public consumption.

Updates current user in the connection with the params.

Functions

Link to this function

change_user(conn, params \\ %{})

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

Creates a changeset from the user fetched in the connection.

Link to this function

create_user(conn, params)

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

Creates a new invited user by the current user in the connection.

Link to this function

load_invited_user_by_token(conn, signed_token)

View Source
@spec load_invited_user_by_token(Plug.Conn.t(), binary()) ::
  {:ok, Plug.Conn.t()} | {:error, Plug.Conn.t()}

Verifies the signed token and fetches invited user.

If a user is found, it'll be assigned to conn.assigns for key :invited_user.

The token should have been signed with sign_invitation_token/2. The token will be decoded and verified with Pow.Plug.verify_token/4.

Link to this function

sign_invitation_token(conn, map)

View Source
@spec sign_invitation_token(Plug.Conn.t(), map()) :: binary()

Signs the invitation token for public consumption.

The token will be signed using Pow.Plug.sign_token/4.

Link to this function

update_user(conn, params)

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

Updates current user in the connection with the params.

Expects the invited user to exist in conn.assigns for key :invited_user.

If successful the session will be regenerated.