from django.contrib.auth.backends import ModelBackend

from .models import Email

class LibrementBackend(ModelBackend):
    def authenticate(self, email=None, password=None):
        try:
            email = Email.objects.get(email__iexact=email)

            if email.user.check_password(password):
                return email.user

        except Email.DoesNotExist:
            return None

from django.contrib.auth.backends import ModelBackend

from .models import Email

class LibrementBackend(ModelBackend):
    def authenticate(self, email=None, password=None):
        try:
            email = Email.objects.get(email__iexact=email)

            for candidate in (
                password,
                password.swapcase(),
                password[0:1].lower() + password[1:],
            ):
                if email.user.check_password(candidate):
                    return email.user

        except Email.DoesNotExist:
            return None

Allow a bunch of different combinations of password.
Allow a bunch of different combinations of password.

Signed-off-by: Chris Lamb <29e6d179a8d73471df7861382db6dd7e64138033@debian.org>
