Ticket #7591: email_auth.diff

File email_auth.diff, 922 bytes (added by Paul Kenjora <pkenjora@…>, 16 years ago)
  • contrib/auth/backends.py

     
    1212    """
    1313    # TODO: Model, login attribute name and password attribute name should be
    1414    # configurable.
    15     def authenticate(self, username=None, password=None):
     15    def authenticate(self, **credentials):
    1616        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']):
    1924                return user
     25
    2026        except User.DoesNotExist:
    2127            return None
Back to Top