View Source PowAssent.Ecto.Schema behaviour (PowAssent v0.4.18)

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

Summary

Functions

Changeset for creating or updating users with a user identity.

Callbacks

Link to this callback

user_identity_changeset(arg1, t, map, arg4)

View Source
@callback user_identity_changeset(
  Ecto.Schema.t() | Ecto.Changeset.t(),
  Ecto.Schema.t(),
  map(),
  map() | nil
) ::
  Ecto.Changeset.t()

Functions

Link to this function

changeset(user_or_changeset, user_identity, attrs, user_id_attrs, config)

View Source
@spec changeset(
  Ecto.Schema.t() | Ecto.Changeset.t(),
  Ecto.Schema.t(),
  map(),
  map() | nil,
  PowAssent.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.