Skip to content
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

500 when logging in after changing email when email verification is mandatory #342

Open
bufke opened this issue Jun 27, 2017 · 0 comments
Open

Comments

@bufke
Copy link

bufke commented Jun 27, 2017

See https://github.com/Tivix/django-rest-auth/blob/master/rest_auth/serializers.py#L105

If using django rest auth with a django based (server side) interface and the django-allauth authentication class it's possible to get in a situation where the user changes their email, authenticates via the api, and gets a 500 error allauth.account.models.DoesNotExist.

This is because changing the user's email (assuming default User model) does not change or add a row to the emailaddress_set. There are situations where we might want users to verify their sign up email, but allow them to change the email without validating it.

I would propose one of the following solutions:

email_address = user.emailaddress_set.filter(user=user, verified=True).exists() this would allow users to sign in with an invalidated changed email - matching django allauth default behavior. The user would still need at least one verified email.

Or

catching the DoesNotExist exception and raising a ValidationError(_('E-mail is not verified.')).

For now it's possible to just extend the LoginSerializer and modify the validate method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant