summaryrefslogtreecommitdiff
path: root/django/contrib/admin/views/decorators.py
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2008-05-15 22:10:53 +0000
committerLuke Plant <L.Plant.98@cantab.net>2008-05-15 22:10:53 +0000
commit7e4718f8d5d511efdbb17e99f37e97f5b91bfd6c (patch)
tree387b7d9e667b2ecff883d715294a03b30a0d0667 /django/contrib/admin/views/decorators.py
parent96f03717728e949dbe21139d6be2754ec75fdc59 (diff)
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
Diffstat (limited to 'django/contrib/admin/views/decorators.py')
-rw-r--r--django/contrib/admin/views/decorators.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/django/contrib/admin/views/decorators.py b/django/contrib/admin/views/decorators.py
index cedb1f9cfd..3039daadb1 100644
--- a/django/contrib/admin/views/decorators.py
+++ b/django/contrib/admin/views/decorators.py
@@ -85,7 +85,13 @@ def staff_member_required(view_func):
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: