Pow.Operations (Pow v1.0.24) View Source

Operation methods that glues operation calls to context module.

A custom context module can be used instead of the default Pow.Ecto.Context if a :users_context key is passed in the configuration.

Link to this section Summary

Functions

Authenticate a user.

Build a changeset from a blank user struct.

Build a changeset from existing user struct.

Create a new user.

Delete an existing user.

Retrieve a keyword list of primary key value(s) from the provided struct.

Retrieve a user with the provided clauses.

Takes a struct and will reload it.

Update an existing user.

Link to this section Functions

Link to this function

authenticate(params, config)

View Source

Specs

authenticate(map(), Pow.Config.t()) :: map() | nil

Authenticate a user.

This calls Pow.Ecto.Context.authenticate/2 or authenticate/1 on a custom context module.

Link to this function

changeset(params, config)

View Source

Specs

changeset(map(), Pow.Config.t()) :: map() | nil

Build a changeset from a blank user struct.

It'll use the schema module fetched from the config through Pow.Config.user!/1.

Link to this function

changeset(user, params, config)

View Source

Specs

changeset(map(), map(), Pow.Config.t()) :: map()

Build a changeset from existing user struct.

It'll call the changeset/2 method on the user struct.

Specs

create(map(), Pow.Config.t()) :: {:ok, map()} | {:error, map()}

Create a new user.

This calls Pow.Ecto.Context.create/2 or create/1 on a custom context module.

Specs

delete(map(), Pow.Config.t()) :: {:ok, map()} | {:error, map()}

Delete an existing user.

This calls Pow.Ecto.Context.delete/2 or delete/1 on a custom context module.

Link to this function

fetch_primary_key_values(struct, config)

View Source

Specs

fetch_primary_key_values(struct(), Pow.Config.t()) ::
  {:ok, keyword()} | {:error, term()}

Retrieve a keyword list of primary key value(s) from the provided struct.

The keys will be fetched from the __schema__/1 method in the struct module. If no __schema__/1 method exists, then it's expected that the struct has :id as its only primary key.

Specs

get_by(Keyword.t() | map(), Pow.Config.t()) :: map() | nil

Retrieve a user with the provided clauses.

This calls Pow.Ecto.Context.get_by/2 or get_by/1 on a custom context module.

Specs

reload(struct(), Pow.Config.t()) :: struct() | nil

Takes a struct and will reload it.

The clauses are fetched with fetch_primary_key_values/2, and the struct loaded with get_by/2. A RuntimeError exception will be raised if the clauses could not be fetched.

Link to this function

update(user, params, config)

View Source

Specs

update(map(), map(), Pow.Config.t()) :: {:ok, map()} | {:error, map()}

Update an existing user.

This calls Pow.Ecto.Context.update/3 or update/2 on a custom context module.