From bb029db4449d01ec9f02283220834cbb428e4771 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Tue, 6 Sep 2011 20:50:00 -0300 Subject: allowed using email address to log in --- askbot/deps/django_authopenid/backends.py | 16 +++++++++++++++- askbot/skins/default/templates/authopenid/signin.html | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/askbot/deps/django_authopenid/backends.py b/askbot/deps/django_authopenid/backends.py index e608086c..18e42586 100644 --- a/askbot/deps/django_authopenid/backends.py +++ b/askbot/deps/django_authopenid/backends.py @@ -3,6 +3,7 @@ multiple login methods supported by the authenticator application """ import datetime +import logging from django.contrib.auth.models import User from django.core.exceptions import ImproperlyConfigured from django.utils.translation import ugettext as _ @@ -48,7 +49,20 @@ class AuthBackend(object): if not user.check_password(password): return None except User.DoesNotExist: - return None + try: + email_address = username + user = User.objects.get(email = email_address) + if not user.check_password(password): + return None + except User.DoesNotExist: + return None + except User.MultipleObjectsReturned: + logging.critical( + ('have more than one user with email %s ' + + 'he/she will not be able to authenticate with ' + + 'the email addres in the place of user name') % email_address + ) + return None else: if login_providers[provider_name]['check_password'](username, password): try: diff --git a/askbot/skins/default/templates/authopenid/signin.html b/askbot/skins/default/templates/authopenid/signin.html index 37636207..49c447a1 100644 --- a/askbot/skins/default/templates/authopenid/signin.html +++ b/askbot/skins/default/templates/authopenid/signin.html @@ -94,7 +94,7 @@ {% endif %} - + -- cgit v1.2.3-1-g7c22
{{login_form.username}}