summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-09-06 20:50:00 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-09-06 20:50:00 -0300
commitbb029db4449d01ec9f02283220834cbb428e4771 (patch)
treeabd5ec457ab9f559a3478c8099feb44b67cd3800
parentea1d7012a52dea5a43040c2a6d7adb41b56971d7 (diff)
downloadaskbot-bb029db4449d01ec9f02283220834cbb428e4771.tar.gz
askbot-bb029db4449d01ec9f02283220834cbb428e4771.tar.bz2
askbot-bb029db4449d01ec9f02283220834cbb428e4771.zip
allowed using email address to log in
-rw-r--r--askbot/deps/django_authopenid/backends.py16
-rw-r--r--askbot/skins/default/templates/authopenid/signin.html2
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 %}
<table class="login">
<tr>
- <td><label for="id_username">{% trans %}Login name{% endtrans %}</label></td>
+ <td><label for="id_username">{% trans %}Login or email{% endtrans %}</label></td>
<td>{{login_form.username}}</td>
</tr>
<tr>