View Source Glific.Users (Glific v5.1.6)

The Users context.

Link to this section Summary

Functions

Return the count of users, using the same filter as list_users

Callback implementation for Pow.Context.create/1.

Creates a user.

Callback implementation for Pow.Context.delete/1.

Deletes a user.

Callback implementation for Pow.Context.get_by/1.

Gets a single user.

Returns the list of filtered users.

Promote the first user of the system to admin automatically. Ignore NGO or SaaS users which are automatically created

Reset user password

Callback implementation for Pow.Context.update/2.

Updates a user.

Link to this section Functions

@spec count_users(map()) :: integer()

Return the count of users, using the same filter as list_users

Callback implementation for Pow.Context.create/1.

@spec create_user(map()) ::
  {:ok, Glific.Users.User.t()} | {:error, Ecto.Changeset.t()}

Creates a user.

examples

Examples

iex> create_user(%{field: value})
{:ok, %User{}}

iex> create_user(%{field: bad_value})
{:error, %Ecto.Changeset{}}

Callback implementation for Pow.Context.delete/1.

@spec delete_user(Glific.Users.User.t()) ::
  {:ok, Glific.Users.User.t()} | {:error, Ecto.Changeset.t()}

Deletes a user.

examples

Examples

iex> delete_user(user)
{:ok, %User{}}

iex> delete_user(user)
{:error, %Ecto.Changeset{}}

Callback implementation for Pow.Context.get_by/1.

@spec get_user!(integer()) :: Glific.Users.User.t()

Gets a single user.

Raises Ecto.NoResultsError if the User does not exist.

examples

Examples

iex> get_user!(123)
%User{}

iex> get_user!(456)
** (Ecto.NoResultsError)
@spec list_users(map()) :: [Glific.Users.User.t()]

Returns the list of filtered users.

examples

Examples

iex> list_users()
[%User{}, ...]
Link to this function

pow_authenticate(params)

View Source
Link to this function

pow_update(user, params)

View Source
Link to this function

promote_first_user(user)

View Source
@spec promote_first_user(Glific.Users.User.t()) :: Glific.Users.User.t()

Promote the first user of the system to admin automatically. Ignore NGO or SaaS users which are automatically created

Link to this function

reset_user_password(user, attrs)

View Source
@spec reset_user_password(Glific.Users.User.t(), map()) ::
  {:ok, Glific.Users.User.t()} | {:error, Ecto.Changeset.t()}

Reset user password

Callback implementation for Pow.Context.update/2.

Link to this function

update_user(user, attrs)

View Source
@spec update_user(Glific.Users.User.t(), map()) ::
  {:ok, Glific.Users.User.t()} | {:error, Ecto.Changeset.t()}

Updates a user.

examples

Examples

iex> update_user(user, %{field: new_value})
{:ok, %User{}}

iex> update_user(user, %{field: bad_value})
{:error, %Ecto.Changeset{}}