Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Luke Plant authored May 15, 2008
8  django/contrib/admin/views/decorators.py
@@ -85,7 +85,13 @@ def _checklogin(request, *args, **kwargs):
85 85
             if '@' in username:
86 86
                 # Mistakenly entered e-mail address instead of username? Look it up.
87 87
                 try:
88  
-                    user = User.objects.get(email=username)
  88
+                    users = list(User.objects.filter(email=username))
  89
+                    if len(users) == 1:
  90
+                        user = users[0]
  91
+                    else:
  92
+                        # Either we cannot find the user, or if more than 1 
  93
+                        # we cannot guess which user is the correct one.
  94
+                        raise User.DoesNotExist()                        
89 95
                 except User.DoesNotExist:
90 96
                     message = _("Usernames cannot contain the '@' character.")
91 97
                 else:

0 notes on commit 7e4718f

Please sign in to comment.
Something went wrong with that request. Please try again.