-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to restrict registration based on email domain #170
Comments
The issue is here: https://github.com/pow-auth/pow_assent/blob/v0.4.7/lib/pow_assent/ecto/user_identities/context.ex#L213 When there's an error on email then it triggers the def user_identity_changeset(user_or_changeset, user_identity, attrs, user_id_attrs) do
user_or_changeset
|> cast(attrs, [:name, :preferred_username, :picture])
|> pow_assent_user_identity_changeset(user_identity, attrs, user_id_attrs)
|> maybe_add_email_domain_error()
|> retrieve_name
end
defp maybe_add_email_domain_error(changeset) do
changeset
|> Ecto.Changeset.get_field(:email)
|> String.ends_with?("@organization.com")
|> case do
true -> changeset
false -> Ecto.Changeset.add_error(changeset, :email_domain, "not valid")
end
end However, I think that the current way email errors are handled is not very flexible. I will see how I can refactor the current logic in PowAssent to make this more flexible and so devs can more easily handle these scenarios. |
Thanks for the code in this issue, I needed this. |
Posted on slack:
The text was updated successfully, but these errors were encountered: