PowAssent v0.2.2 PowAssent.Plug View Source

Plug helper methods.

If you wish to configure PowAssent through the Pow plug interface rather than environment config, please add PowAssent config with :pow_assent config:

plug Pow.Plug.Session,
  repo: MyApp.Repo,
  user: MyApp.User,
  pow_assent: [
    http_adapter: PowAssent.HTTPAdapter.Mint,
    json_library: Poison,
    user_identities_context: MyApp.UserIdentities
  ]

Link to this section Summary

Functions

Authenticates a user with provider and provider user params

Calls the authorize_url method for the provider strategy

Lists available providers for connection

Calls the callback method for the provider strategy

Creates an identity for a user with provider and provider user params

Create a user with the provider and provider user params

Deletes the associated user identity for the current user and provider

Lists associated providers for the user

Link to this section Functions

Link to this function authenticate(conn, provider, user_params) View Source
authenticate(Plug.Conn.t(), binary(), map()) ::
  {:ok, Plug.Conn.t()} | {:error, Plug.Conn.t()}

Authenticates a user with provider and provider user params.

If successful, a new session will be created.

Link to this function authorize_url(conn, provider, redirect_uri) View Source
authorize_url(Plug.Conn.t(), binary(), binary()) ::
  {:ok, binary(), Plug.Conn.t()} | {:error.any(), Plug.Conn.t()}

Calls the authorize_url method for the provider strategy.

A generated authorization URL will be returned. If :state is returned from the provider, it’ll be added to the connection as private key :pow_assent_state.

Link to this function available_providers(conn) View Source
available_providers(Plug.Conn.t() | PowAssent.Config.t()) :: [atom()]

Lists available providers for connection.

Link to this function callback(conn, provider, params, redirect_uri) View Source
callback(Plug.Conn.t(), binary(), map(), binary()) ::
  {:ok, map(), Plug.Conn.t()} | {:error, any(), Plug.Conn.t()}

Calls the callback method for the provider strategy.

Returns the user params fetched from the provider.

:state will be added to the provider config if :pow_assent_state is present as a private key in the connection.

Link to this function create_identity(conn, provider, user_params) View Source
create_identity(Plug.Conn.t(), binary(), map()) ::
  {:ok, map(), Plug.Conn.t()}
  | {:error, {:bound_to_different_user, map()} | map(), Plug.Conn.t()}

Creates an identity for a user with provider and provider user params.

If successful, a new session will be created.

Link to this function create_user(conn, provider, user_params, user_id_params \\ nil) View Source
create_user(Plug.Conn.t(), binary(), map(), map() | nil) ::
  {:ok, map(), Plug.Conn.t()}
  | {:error,
     {:bound_to_different_user | :invalid_user_id_field, map()} | map(),
     Plug.Conn.t()}

Create a user with the provider and provider user params.

If successful, a new session will be created.

Link to this function delete_identity(conn, provider) View Source
delete_identity(Plug.Conn.t(), binary()) ::
  {:ok, map(), Plug.Conn.t()} | {:error, {:no_password, map()}, Plug.Conn.t()}

Deletes the associated user identity for the current user and provider.

Link to this function providers_for_current_user(conn) View Source
providers_for_current_user(Plug.Conn.t()) :: [atom()]

Lists associated providers for the user.