-
Notifications
You must be signed in to change notification settings - Fork 461
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
Duplicated email address leads to 500 error #716
Comments
I have not tested it but I think if we will allow duplicate emails, not only Activation (with possible solution above), but more actions will have problem. .. if so, this can be closed; but I let it open, because I am curious for meaning of others. |
Thanks for creating the ticket, you're right. PRs welcome! |
I have found some time to have a look into that. This integrity check should be implemented in the DB with a unique constraint. If such index existed, the create serializer will prevent from creating a duplicate user. Lines 37 to 44 in 0cef72f
But I agree, this could be a useful feature in Djoser as well. |
I closed the PR above as we can't justify an additional query to the DB to meet the criteria of a few. I will leave this ticket open. If someone else has a better idea, let me know. Depending on the project setup and requirements, it may or may not be a bug. |
I think 2+ users can share same e-mail address.
However when 2+ users with same address are inactive, djoser will fail so there is no possibility to activate such users.
(And this is danger, because the user can try add next usernames to make the account with such email working.)
As you can see, only Django, Rest_framework & Djoser are in the traceback, so I think Djoser should be fixed.
The problem is in the
serializers.py
,class UserFunctionsMixin
,def get_user()
where the orm callUser._default_manager.get()
is handled forUser.DoesNotExist
but not forUser.MultipleObjectsReturned
.I think instead of
.get()
we could use.filter().first()
here (with appropriate removal of try/except).This would make the user activating possible, the 1st one first, then the next..
Of course the users identification by email and not by username is not good here.
However I think such solution could give some improvement still.
The other question, which I am not able to answer now, is:
Is it possible to fix it in this way for all scenarios where
UserFunctionsMixin
is used?The text was updated successfully, but these errors were encountered: