You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

auth_backends.py 471B

1234567891011121314
  1. from django.contrib.auth.models import User
  2. from django.contrib.auth.backends import ModelBackend
  3. class Emailbackend(ModelBackend):
  4. def authenticate(self, email=None, password=None, *args, **kwargs):
  5. if not email:
  6. email = kwargs.pop('username', None)
  7. try:
  8. user = User.objects.get(email=email)
  9. if user.check_password(password):
  10. return user
  11. except User.DoesNotExist:
  12. return None