Skip to content

Commit

Permalink
fix:import-duplicate-usernames
Browse files Browse the repository at this point in the history
  • Loading branch information
nick2432 committed Feb 23, 2024
1 parent 7b08d47 commit 2d9d954
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kolibri/core/auth/management/commands/bulkimportusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,13 @@ def get_username(self, row):
username = row.get(self.header_translation["USERNAME"])
lowercase_username = username.lower()

# Check if a user with the provided username exists (case-insensitive)
existing_user = FacilityUser.objects.filter(username__iexact=lowercase_username).first()
# Convert existing keys in self.users to lowercase
if existing_user:
return None # Duplicate username
# Convert existing keys in self.users to lowercase
lowercase_users = {key.lower(): value for key, value in self.users.items()}

if lowercase_username in lowercase_users:
return None # Duplicate username

Expand Down

0 comments on commit 2d9d954

Please sign in to comment.