Pow v1.0.20 PowInvitation.Ecto.Schema View Source
Handles the invitation schema for user.
Customize PowInvitation associations or fields
If you need to modify any of the associations or fields that PowInvitation
adds to the user schema, you can override them by defining them before
pow_user_fields/0
:
defmodule MyApp.Users.User do
use Ecto.Schema
use Pow.Ecto.Schema
use Pow.Extension.Ecto.Schema,
extensions: [PowInvitation]
schema "users" do
belongs_to :invited_by, __MODULE__
has_many :invited_users __MODULE__, foreign_key: :invited_by_id, on_delete: delete_all
field :invitation_token, :string
field :invitation_accepted_at, :utc_datetime
pow_user_fields()
timestamps()
end
end
Link to this section Summary
Link to this section Functions
accept_invitation_changeset(changeset, attrs)
View Sourceaccept_invitation_changeset(Ecto.Schema.t() | Ecto.Changeset.t(), map()) :: Ecto.Changeset.t()
Accepts an invitation.
The changeset method in user schema module is called, and
:invitation_accepted_at
will be updated. The password can be set, and the
user id updated.
invite_changeset(changeset, invited_by, attrs)
View Sourceinvite_changeset(Ecto.Schema.t() | Ecto.Changeset.t(), Ecto.Schema.t(), map()) :: Ecto.Changeset.t()
Invites user.
It's important to note that this changeset should not include the changeset
method in the user schema module if PowEmailConfirmation
has been enabled.
This is because the e-mail is assumed confirmed already if the user can
accept the invitation.
A unique :invitation_token
will be generated, and invited_by
association
will be set. Only the user id will be set, and the persisted user won't have
any password for authentication.