PowAssent v0.3.0 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
authenticate(conn, map)
View Source
authenticate(Plug.Conn.t(), map()) ::
{:ok, Plug.Conn.t()} | {:error, Plug.Conn.t()}
authenticate(Plug.Conn.t(), 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.
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()}
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 :session_params
is
returned from the provider, it'll be added to the connection as private key
:pow_assent_session_params
.
available_providers(conn)
View Source
available_providers(Plug.Conn.t() | PowAssent.Config.t()) :: [atom()]
available_providers(Plug.Conn.t() | PowAssent.Config.t()) :: [atom()]
Lists available providers for connection.
callback(conn, provider, params, redirect_uri)
View Source
callback(Plug.Conn.t(), binary(), map(), binary()) ::
{:ok, map(), map(), Plug.Conn.t()} | {:error, any(), Plug.Conn.t()}
callback(Plug.Conn.t(), binary(), map(), binary()) :: {:ok, map(), map(), Plug.Conn.t()} | {:error, any(), Plug.Conn.t()}
Calls the callback method for the provider strategy.
Returns the user identity params and user params fetched from the provider.
:session_params
will be added to the provider config if
:pow_assent_session_params
is present as a private key in the connection.
create_identity(conn, user_identity_params)
View Source
create_identity(Plug.Conn.t(), map()) ::
{:ok, map(), Plug.Conn.t()}
| {:error, {:bound_to_different_user, map()} | map(), Plug.Conn.t()}
create_identity(Plug.Conn.t(), 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.
create_user(conn, user_identity_params, user_params, user_id_params \\ nil)
View Source
create_user(Plug.Conn.t(), map(), map(), map() | nil) ::
{:ok, map(), Plug.Conn.t()}
| {:error,
{:bound_to_different_user | :invalid_user_id_field, map()} | map(),
Plug.Conn.t()}
create_user(Plug.Conn.t(), map(), 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.
delete_identity(conn, provider)
View Source
delete_identity(Plug.Conn.t(), binary()) ::
{:ok, map(), Plug.Conn.t()} | {:error, {:no_password, map()}, Plug.Conn.t()}
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.
providers_for_current_user(conn)
View Source
providers_for_current_user(Plug.Conn.t()) :: [atom()]
providers_for_current_user(Plug.Conn.t()) :: [atom()]
Lists associated providers for the user.