Merge branch 'hotfix/lil-600' into 'master'

Hotfix/lil 600

See merge request lilcity/backend!96
remotes/origin/hotfix/LIL-661
cfwme 8 years ago
commit c35637161d
  1. 21
      apps/auth/backend.py
  2. 1
      project/settings.py

@ -0,0 +1,21 @@
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth import get_user_model
User = get_user_model()
class CaseInsensitiveModelBackend(ModelBackend):
def authenticate(self, username=None, password=None):
try:
user = User.objects.get(**{f'{User.USERNAME_FIELD}__iexact': username})
if user.check_password(password):
return user
except User.DoesNotExist:
return None
def get_user(self, user_id):
try:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None

@ -142,6 +142,7 @@ AUTH_PASSWORD_VALIDATORS = [
AUTH_USER_MODEL = 'user.User'
AUTHENTICATION_BACKENDS = ['apps.auth.backend.CaseInsensitiveModelBackend']
# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/

Loading…
Cancel
Save