PowAssent v0.4.5 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.
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.
Will upsert identity for the current user.
Link to this section Functions
authenticate(conn, map)
View Sourceauthenticate(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 Sourceauthorize_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
.
If :nonce
is set to true
in the provider configuration, a randomly
generated nonce will be added to the configuration.
available_providers(conn)
View Sourceavailable_providers(Plug.Conn.t() | PowAssent.Config.t()) :: [atom()]
Lists available providers for connection.
callback(conn, provider, params, redirect_uri)
View Sourcecallback(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_user(conn, user_identity_params, user_params, user_id_params \\ nil)
View Sourcecreate_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 Sourcedelete_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 Sourceproviders_for_current_user(Plug.Conn.t()) :: [atom()]
Lists associated providers for the user.
upsert_identity(conn, user_identity_params)
View Sourceupsert_identity(Plug.Conn.t(), map()) :: {:ok, map(), Plug.Conn.t()} | {:error, {:bound_to_different_user, map()} | map(), Plug.Conn.t()}
Will upsert identity for the current user.
If successful, a new session will be created.