Ticket #7591: email_auth.diff
File email_auth.diff, 922 bytes (added by , 16 years ago) |
---|
-
contrib/auth/backends.py
12 12 """ 13 13 # TODO: Model, login attribute name and password attribute name should be 14 14 # configurable. 15 def authenticate(self, username=None, password=None):15 def authenticate(self, **credentials): 16 16 try: 17 user = User.objects.get(username=username) 18 if user.check_password(password): 17 user = None 18 if 'username' in credentials: 19 user = User.objects.get(username=credentials['username']) 20 else: 21 user = User.objects.get(email=credentials['email']) 22 23 if user.check_password(credentials['password']): 19 24 return user 25 20 26 except User.DoesNotExist: 21 27 return None