Skip to content

Commit

Permalink
fix:username-disambiguation
Browse files Browse the repository at this point in the history
  • Loading branch information
nick2432 committed Jan 12, 2024
1 parent de2566c commit 5bd813d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kolibri/core/auth/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def authenticate(self, request, username=None, password=None, **kwargs):
# If case-sensitive login fails, attempt case-insensitive login
user = self.authenticate_case_insensitive(username, password, facility)
return user

def _authenticate_users(self, users, password, facility):
if facility:
users = users.filter(facility=facility)
Expand All @@ -50,13 +51,15 @@ def _authenticate_users(self, users, password, facility):
):
return user
return None

def authenticate_case_sensitive(self, username, password, facility):
users = FacilityUser.objects.filter(username=username)
return self._authenticate_users(users, password, facility)

def authenticate_case_insensitive(self, username, password, facility):
users = FacilityUser.objects.filter(username__iexact=username)
return self._authenticate_users(users, password, facility)

def get_user(self, user_id):
"""
Gets a user. Auth backends are required to implement this.
Expand Down

0 comments on commit 5bd813d

Please sign in to comment.