Created
August 31, 2010 11:06
-
-
Save dickbrouwer/558872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
from django.contrib.auth.backends import ModelBackend | |
class CIModelBackend(ModelBackend): | |
""" | |
Overrides the default authentication backend (ModelBackend) | |
to support case-insensitive login. | |
""" | |
def authenticate(self, username=None, password=None): | |
try: | |
user = User.objects.get(username__iexact=username) | |
if user.check_password(password): | |
return user | |
except User.DoesNotExist: | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment