Django

Code

Changeset 7535

Show
Ignore:
Timestamp:
05/15/08 17:10:53 (2 months ago)
Author:
lukeplant
Message:

Fixed bug in staff_member_required decorator for the case where users share an email address.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/admin/views/decorators.py

    r7521 r7535  
    8686                # Mistakenly entered e-mail address instead of username? Look it up. 
    8787                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()                         
    8995                except User.DoesNotExist: 
    9096                    message = _("Usernames cannot contain the '@' character.")