PowAssent v0.1.0 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
has_many :user_identities,
MyApp.UserIdentities.UserIdentity,
on_delete: :delete_all
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(user, 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, 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(), 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, map)
View Source
user_identity_changeset( Ecto.Schema.t() | Ecto.Changeset.t(), Ecto.Schema.t(), map(), map() ) :: Ecto.Changeset.t()