1
0
mirror of https://github.com/krislamo/DJ-BaseSite synced 2024-11-13 00:00:34 +00:00
DJ-BaseSite/myproject/backends/AuthOverride.py

13 lines
385 B
Python
Raw Normal View History

2012-10-13 14:35:48 +00:00
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