Merge main and common apps, extract authentication functionality to new authentication app. Closes issues #179 and #180

This commit is contained in:
Roberto Rosario
2015-04-06 16:09:54 -04:00
parent 5367bee1b2
commit 23fc9f1e36
165 changed files with 5320 additions and 13244 deletions

View File

@@ -0,0 +1,22 @@
from django.contrib.auth import get_user_model
from django.contrib.auth.backends import ModelBackend
class EmailAuthBackend(ModelBackend):
"""
Email Authentication Backend
Allows a user to sign in using an email/password pair rather than
a username/password pair.
"""
def authenticate(self, email=None, password=None):
UserModel = get_user_model()
try:
user = UserModel.objects.get(email=email)
if user.check_password(password):
return user
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)