Skip to content

Instantly share code, notes, and snippets.

@dickbrouwer
Created August 31, 2010 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dickbrouwer/558872 to your computer and use it in GitHub Desktop.
Save dickbrouwer/558872 to your computer and use it in GitHub Desktop.
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