Pow v0.1.0-alpha.5 Pow.Ecto.Context behaviour View Source
Handles pow users context for user.
Usage
This module will be used by pow by default. If you
wish to have control over context methods, you can
do configure lib/my_project/users/users.ex
the following way:
defmodule MyApp.Users do
use Pow.Ecto.Context,
repo: MyApp.Repo,
user: MyApp.Users.User
def create(params) do
pow_create(params)
end
end
Remember to update configuration with users_context: MyApp.Users
.
The following Pow methods can be accessed:
pow_authenticate/1
pow_create/1
pow_update/2
pow_delete/1
pow_get_by/1
Configuration options
:repo
- the ecto repo module (required):user
- the user schema module (required)
Link to this section Summary
Functions
Finds a user based on the user id, and verifies the password on the user
Creates a new user
Deletes the user
Inserts a changeset to the database
Updates a changeset in the database
Retrieves an user by the provided clauses
Retrieves the repo module from the config, or raises an exception
Updates the user
Retrieves the user schema module from the config, or raises an exception
Link to this section Types
Link to this section Functions
authenticate(Pow.Config.t(), map()) :: user() | nil
Finds a user based on the user id, and verifies the password on the user.
User schema module and repo module will be fetched from the config. The user id field is fetched from the user schema module.
create(Pow.Config.t(), map()) :: {:ok, user()} | {:error, Ecto.Changeset.t()}
Creates a new user.
User schema module and repo module will be fetched from config.
delete(Pow.Config.t(), user()) :: {:ok, user()} | {:error, Ecto.Changeset.t()}
Deletes the user.
Repo module will be fetched from the config.
do_insert(Ecto.Changeset.t(), Pow.Config.t()) :: {:ok, user()} | {:error, Ecto.Changeset.t()}
Inserts a changeset to the database.
If succesful, the returned row will be reloaded from the database.
do_update(Ecto.Changeset.t(), Pow.Config.t()) :: {:ok, user()} | {:error, Ecto.Changeset.t()}
Updates a changeset in the database.
If succesful, the returned row will be reloaded from the database.
get_by(Pow.Config.t(), Keyword.t() | map()) :: user() | nil
Retrieves an user by the provided clauses.
User schema module and repo module will be fetched from the config.
Retrieves the repo module from the config, or raises an exception.
update(Pow.Config.t(), user(), map()) :: {:ok, user()} | {:error, Ecto.Changeset.t()}
Updates the user.
User schema module will be fetched from provided user and repo will be fetched from the config.
user_schema_mod(Pow.Config.t()) :: atom() | no_return()
Retrieves the user schema module from the config, or raises an exception.
Link to this section Callbacks
create(map()) :: {:ok, user()} | {:error, Ecto.Changeset.t()}
delete(user()) :: {:ok, user()} | {:error, Ecto.Changeset.t()}
update(user(), map()) :: {:ok, user()} | {:error, Ecto.Changeset.t()}