Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug in staff_member_required decorator for the case where users…

… share an email address.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7535 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 7e4718f8d5d511efdbb17e99f37e97f5b91bfd6c 1 parent 96f0371
@spookylukey spookylukey authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 django/contrib/admin/views/decorators.py
View
8 django/contrib/admin/views/decorators.py
@@ -85,7 +85,13 @@ def _checklogin(request, *args, **kwargs):
if '@' in username:
# Mistakenly entered e-mail address instead of username? Look it up.
try:
- user = User.objects.get(email=username)
+ users = list(User.objects.filter(email=username))
+ if len(users) == 1:
+ user = users[0]
+ else:
+ # Either we cannot find the user, or if more than 1
+ # we cannot guess which user is the correct one.
+ raise User.DoesNotExist()
except User.DoesNotExist:
message = _("Usernames cannot contain the '@' character.")
else:
Please sign in to comment.
Something went wrong with that request. Please try again.