Pow v1.0.11 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):repo_opts
- keyword list options for the repo,:prefix
can be set here
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.
See Pow.Config.repo!/1
.
Updates the user.
See Pow.Config.user!/1
.
Link to this section Types
changeset()
View Source
changeset() :: map()
changeset() :: map()
user()
View Source
user() :: map()
user() :: map()
Link to this section Functions
authenticate(params, config)
View Source
authenticate(map(), Pow.Config.t()) :: user() | nil
authenticate(map(), Pow.Config.t()) :: 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.
The method will return nil if either the user id or password is nil.
create(params, config)
View Source
create(map(), Pow.Config.t()) :: {:ok, user()} | {:error, changeset()}
create(map(), Pow.Config.t()) :: {:ok, user()} | {:error, changeset()}
Creates a new user.
User schema module and repo module will be fetched from config.
delete(user, config)
View Source
delete(user(), Pow.Config.t()) :: {:ok, user()} | {:error, changeset()}
delete(user(), Pow.Config.t()) :: {:ok, user()} | {:error, changeset()}
Deletes the user.
Repo module will be fetched from the config.
do_insert(changeset, config)
View Source
do_insert(changeset(), Pow.Config.t()) :: {:ok, user()} | {:error, changeset()}
do_insert(changeset(), Pow.Config.t()) :: {:ok, user()} | {:error, changeset()}
Inserts a changeset to the database.
If succesful, the returned row will be reloaded from the database.
do_update(changeset, config)
View Source
do_update(changeset(), Pow.Config.t()) :: {:ok, user()} | {:error, changeset()}
do_update(changeset(), Pow.Config.t()) :: {:ok, user()} | {:error, changeset()}
Updates a changeset in the database.
If succesful, the returned row will be reloaded from the database.
get_by(clauses, config)
View Source
get_by(Keyword.t() | map(), Pow.Config.t()) :: user() | nil
get_by(Keyword.t() | map(), Pow.Config.t()) :: user() | nil
Retrieves an user by the provided clauses.
User schema module and repo module will be fetched from the config.
repo(config) View Source
See Pow.Config.repo!/1
.
update(user, params, config)
View Source
update(user(), map(), Pow.Config.t()) :: {:ok, user()} | {:error, changeset()}
update(user(), map(), Pow.Config.t()) :: {:ok, user()} | {:error, changeset()}
Updates the user.
User schema module will be fetched from provided user and repo will be fetched from the config.
user_schema_mod(config) View Source
See Pow.Config.user!/1
.