View Source PowInvitation.Plug (Pow v1.0.39)

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

change_user(conn, params \\ %{})

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

Creates a changeset from the user fetched in the connection.

create_user(conn, params)

@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.

load_invited_user_by_token(conn, signed_token)

@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.

sign_invitation_token(conn, map)

@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.

update_user(conn, params)

@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.