Pow: Make `accept_invitation_changeset` overridable like `invite_changeset`

Created on 2 Mar 2020  路  4Comments  路  Source: danschultzer/pow

What do you think about making the accept_invitation_changeset overridable like the invite_changet?

Here is what I would like to be able to do:

  @spec accept_invitation_changeset(Ecto.Schema.t() | Ecto.Changeset.t(), map()) ::
          Ecto.Changeset.t()
  def accept_invitation_changeset(user_or_changeset, params) do
    user_or_changeset
    |> pow_accept_invitation_changeset(params)
    |> Ecto.Changeset.put_change(:status, :active)
  end

Most helpful comment

Released in v1.0.19 馃殌

All 4 comments

Yeah, that makes sense.

An alternative could be to let the accept_invitation_changeset/2 method change the :invitation_accepted_at before calling changeset/2 on the user, and the logic can instead be put there. I prefer your suggestion though.

I'll look through the codebase to see if this is something that should be generally possible for all extension changeset methods, e.g. reset_password_changeset/2.

Got around to it with #446. Makes a lot of sense that you can override all extension changeset methods, so it's easy to customize the the flow and that by default all changeset methods are called on the user module rather than being tied to the Pow modules. I'll have to review it with fresh eyes and then get it merged 馃殌

Awesome! This is going to make Pow even nicer to use. Thanks!

Released in v1.0.19 馃殌

Was this page helpful?
0 / 5 - 0 ratings