How do you want to verify and use the referral code during registration? You can set up a changeset as described in the Creating custom controller callbacks with Pow - #2 by danschultzer thread. It describes how to check for an association only when the user is created.
Yeah, but you only need to override that single route:
scope "/", MyAppWeb do
resources "/registration", RegistrationController, singleton: true, only: [:create]
end
scope "/" do
pow_routes()
end
No.
See above.
Alternatively you can set up a custom context:
defmodule MyApp.Users do
use Pow.Ecto.Context,
repo: MyApp.Repo,
user: MyApp.Users.User
def create(params) do
case verify_referral_code(params) do
{:ok, _any} -> pow_create(params)
{:error, changeset} -> {:error, changeset}
end
end
# ...
end
If the referral code is also used in the PowAssent callback phase then you would need to do this for the user identities context too.