Source code for herobase.backends

# -*- coding: utf-8 -*-
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.models import User

[docs]class EmailAuthBackend(ModelBackend): """Custom Authentication Backend for user validation with email addy and password.""" def authenticate(self, username=None, password=None): try: user = User.objects.get(email=username) if user.check_password(password): return user except User.DoesNotExist: return None