PowAssent v0.3.1 PowAssent.Ecto.Schema behaviour View Source

Handles the Ecto schema for user.

user_id_attrs is provided by the user in a registration step.

Usage

Configure lib/my_project/users/user.ex the following way:

defmodule MyApp.Users.User do
  use Ecto.Schema
  use Pow.Ecto.Schema
  use PowAssent.Ecto.Schema

  schema "users" do
    field :custom_field, :string

    pow_user_fields()

    timestamps()
  end

  def changeset(user_or_changeset, attrs) do
    user_or_changeset
    |> Ecto.Changeset.cast(attrs, [:custom_field])
    |> pow_changeset(attrs)
  end

  def user_identity_changeset(user_or_changeset, user_identity, attrs, user_id_attrs) do
    user_or_changeset
    |> Ecto.Changeset.cast(attrs, [:custom_field])
    |> pow_assent_user_identity_changeset(user_identity, attrs, user_id_attrs)
  end
end

Link to this section Summary

Functions

Changeset for creating or updating users with a user identity

Link to this section Functions

Link to this function

changeset(user_or_changeset, user_identity, attrs, user_id_attrs, config) View Source
changeset(
  Ecto.Schema.t() | Ecto.Changeset.t(),
  Ecto.Schema.t(),
  map(),
  map() | nil,
  Config.t()
) :: Ecto.Changeset.t()

Changeset for creating or updating users with a user identity.

Only Pow.Ecto.Schema.Changeset.user_id_field_changeset/3 is used for validation as password is not required.

Link to this section Callbacks

Link to this callback

user_identity_changeset(arg0, arg1, map, arg3) View Source
user_identity_changeset(
  Ecto.Schema.t() | Ecto.Changeset.t(),
  Ecto.Schema.t(),
  map(),
  map() | nil
) :: Ecto.Changeset.t()