From a3bd6d3f64d9ba7d941d20844ee4337c5f51a783 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Mon, 28 Jul 2014 03:16:52 -0400 Subject: [PATCH] Update authentication backend as per Django 1.6 updates --- mayan/apps/common/auth/email_auth_backend.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mayan/apps/common/auth/email_auth_backend.py b/mayan/apps/common/auth/email_auth_backend.py index 1048e8c788..3caf5f0804 100644 --- a/mayan/apps/common/auth/email_auth_backend.py +++ b/mayan/apps/common/auth/email_auth_backend.py @@ -1,5 +1,4 @@ -# From: http://www.micahcarrick.com/django-email-authentication.html -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model from django.contrib.auth.backends import ModelBackend @@ -12,12 +11,12 @@ class EmailAuthBackend(ModelBackend): """ def authenticate(self, email=None, password=None): - """ - Authenticate a user based on email address as the user name. - """ + UserModel = get_user_model() try: - user = User.objects.get(email=email) + user = UserModel.objects.get(email=email) if user.check_password(password): return user - except User.DoesNotExist: - return None + except UserModel.DoesNotExist: + # Run the default password hasher once to reduce the timing + # difference between an existing and a non-existing user (#20760). + UserModel().set_password(password)