mirror of
https://github.com/krislamo/DJ-BaseSite
synced 2024-11-09 23:00:34 +00:00
13 lines
385 B
Python
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 |