Update authentication backend as per Django 1.6 updates
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
# From: http://www.micahcarrick.com/django-email-authentication.html
|
from django.contrib.auth import get_user_model
|
||||||
from django.contrib.auth.models import User
|
|
||||||
from django.contrib.auth.backends import ModelBackend
|
from django.contrib.auth.backends import ModelBackend
|
||||||
|
|
||||||
|
|
||||||
@@ -12,12 +11,12 @@ class EmailAuthBackend(ModelBackend):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def authenticate(self, email=None, password=None):
|
def authenticate(self, email=None, password=None):
|
||||||
"""
|
UserModel = get_user_model()
|
||||||
Authenticate a user based on email address as the user name.
|
|
||||||
"""
|
|
||||||
try:
|
try:
|
||||||
user = User.objects.get(email=email)
|
user = UserModel.objects.get(email=email)
|
||||||
if user.check_password(password):
|
if user.check_password(password):
|
||||||
return user
|
return user
|
||||||
except User.DoesNotExist:
|
except UserModel.DoesNotExist:
|
||||||
return None
|
# Run the default password hasher once to reduce the timing
|
||||||
|
# difference between an existing and a non-existing user (#20760).
|
||||||
|
UserModel().set_password(password)
|
||||||
|
|||||||
Reference in New Issue
Block a user