pow-auth / pow_assent

Multi-provider authentication for your Pow enabled app
https://powauth.com
MIT License
321 stars 50 forks source link

Pass userinfo along with the other params to the UserIdentity changeset #160

Closed danschultzer closed 3 years ago

danschultzer commented 4 years ago

With #66 everything but the userinfo claims was passed on. It makes sense to have access to those claims too though. Now you'll be able to do this:

# lib/my_app/user_identities/user_identity.ex
defmodule MyApp.UserIdentities.UserIdentity do
  use Ecto.Schema
  use PowAssent.Ecto.UserIdentities.Schema,
    user: MyApp.Users.User

  schema "user_identities" do
    field :name, :string

    pow_assent_user_identity_fields()

    timestamps()
  end

  def changeset(user_identity_or_changeset, attrs) do
    userinfo_params = Map.get(attrs, "userinfo", %{})

    user_identity_or_changeset
    |> pow_assent_changeset(attrs)
    |> Ecto.Changeset.cast(userinfo_params, [:name])
  end
end