Self hosted FLOSS fitness/workout, nutrition and weight tracker
Allow user to login with the email address #164
Mihail Burduja1601e5e4253c
diff --git a/wger/settings_global.py b/wger/settings_global.pyindex a523b67f8..16ac6ffe8 100644--- a/wger/settings_global.py+++ b/wger/settings_global.py@@ -129,6 +129,7 @@ MIDDLEWARE_CLASSES = (AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend','django_browserid.auth.BrowserIDBackend',+ 'wger.utils.helpers.EmailAuthBackend')# Set the context processorsdiff --git a/wger/utils/helpers.py b/wger/utils/helpers.pyindex 104950872..0d52ff5c4 100644--- a/wger/utils/helpers.py+++ b/wger/utils/helpers.py@@ -34,6 +34,25 @@ from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encodelogger = logging.getLogger(__name__)+class EmailAuthBackend(object):++ def authenticate(self, username=None, password=None):+ try:+ user = User.objects.get(email=username)+ if user.check_password(password):+ return user+ return None+ except User.DoesNotExist:+ return None+++ def get_user(self, user_id):+ try:+ return User.objects.get(pk=user_id)+ except User.DoesNotExist:+ return None++class DecimalJsonEncoder(json.JSONEncoder):'''Custom JSON encoder.