PowAssent.Ecto.UserIdentities.Context behaviour (PowAssent v0.4.10) View Source

Handles pow assent user identity context for user identities.

Usage

This module will be used by PowAssent by default. If you wish to have control over context methods, you can do configure lib/my_project/user_identities/user_identities.ex the following way:

defmodule MyApp.UserIdentities do
  use PowAssent.Ecto.UserIdentities.Context,
    repo: MyApp.Repo,
    user: MyApp.Users.User

  def all(user) do
    pow_assent_all(user)
  end
end

Remember to update the PowAssent configuration with user_identities_context: MyApp.UserIdentities.

The following Pow methods can be accessed:

  • pow_assent_get_user_by_provider_uid/3
  • pow_assent_upsert/2
  • pow_assent_create_user/4
  • pow_assent_delete/2
  • pow_assent_all/1

Configuration options

  • :repo - the ecto repo module (required)
  • :user - the user schema module (required)

Link to this section Summary

Functions

Fetches all user identities for user.

Deletes a user identity for the provider and user.

Finds a user based on the provider and uid.

Link to this section Types

Specs

changeset() :: map()

Specs

user() :: map()

Specs

user_id_params() :: map()

Specs

user_identity() :: map()
Link to this type

user_identity_params()

View Source

Specs

user_identity_params() :: map()

Specs

user_params() :: map()

Link to this section Functions

Specs

Fetches all user identities for user.

Repo module will be fetched from config.

Link to this function

create_user(user_identity_params, user_params, user_id_params, config)

View Source

Specs

create_user(
  user_identity_params(),
  user_params(),
  user_id_params() | nil,
  PowAssent.Config.t()
) ::
  {:ok, user()}
  | {:error, {:bound_to_different_user | :invalid_user_id_field, changeset()}}
  | {:error, changeset()}

Creates a user with user identity.

User schema module and repo module will be fetched from config.

Link to this function

delete(user, provider, config)

View Source

Specs

delete(user(), binary(), PowAssent.Config.t()) ::
  {:ok, {number(), nil}} | {:error, {:no_password, changeset()}}

Deletes a user identity for the provider and user.

Repo module will be fetched from config.

Link to this function

get_user_by_provider_uid(provider, uid, config)

View Source

Specs

get_user_by_provider_uid(binary(), binary() | integer(), PowAssent.Config.t()) ::
  user() | nil

Finds a user based on the provider and uid.

User schema module and repo module will be fetched from the config.

See Pow.Config.repo!/1.

Link to this function

upsert(user, user_identity_params, config)

View Source

Specs

upsert(user(), user_identity_params(), PowAssent.Config.t()) ::
  {:ok, user_identity()}
  | {:error, {:bound_to_different_user, changeset()}}
  | {:error, changeset()}

Upserts a user identity.

If a matching user identity already exists for the user, the identity will be updated, otherwise a new identity is inserted.

Repo module will be fetched from config.

See Pow.Config.user!/1.

Link to this section Callbacks

Specs

all(user()) :: [user_identity()]
Link to this callback

create(user, user_identity_params)

View Source

Specs

create(user(), user_identity_params()) :: any()
Link to this callback

create_user(user_identity_params, user_params, arg3)

View Source

Specs

create_user(user_identity_params(), user_params(), user_id_params() | nil) ::
  {:ok, user()}
  | {:error, {:bound_to_different_user | :invalid_user_id_field, changeset()}}
  | {:error, changeset()}

Specs

delete(user(), binary()) ::
  {:ok, {number(), nil}} | {:error, {:no_password, changeset()}}
Link to this callback

get_user_by_provider_uid(binary, binary)

View Source

Specs

get_user_by_provider_uid(binary(), binary()) :: user() | nil
Link to this callback

upsert(user, user_identity_params)

View Source

Specs

upsert(user(), user_identity_params()) ::
  {:ok, user_identity()}
  | {:error, {:bound_to_different_user, changeset()}}
  | {:error, changeset()}