1
0
mirror of https://github.com/krislamo/DJ-BaseSite synced 2024-11-09 23:00:34 +00:00
DJ-BaseSite/myproject/backends/AuthOverride.py
2012-10-13 07:35:48 -07:00

13 lines
385 B
Python

from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.models import User
class CaseInsensitiveModelBackend(ModelBackend):
def authenticate(self, username=None, password=None):
try:
user = User.objects.get(username__iexact=username)
if user.check_password(password):
return user
else:
return None
except User.DoesNotExist:
return None