Skip to content

Make usernames case-insensitive - #82

Merged
summitt merged 1 commit into
mainfrom
fix/case-insensitive-usernames
Nov 23, 2026
Merged

summitt merged 1 commit into
mainfrom
fix/case-insensitive-usernames

Conversation

@summitt

@summitt summitt commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Problem

Sign-in matched the username exactly, so someone created as bob couldn't log in by typing Bob. Creating or renaming a user only rejected exact duplicates, so Bob and bob could exist as two separate accounts.

Change

  • Login ignores case. An exact match is tried first, so existing accounts that differ only in case can each still sign in. If there's no exact match and several accounts match ignoring case, login is refused rather than guessing which one was meant.
  • The token carries the stored username, not the typed one. Everything downstream (/auth/me, permission lookups) finds the user by that name, so a case mismatch there would break the session.
  • Create and rename check for duplicates ignoring case. An edit that keeps the same name skips the check, so it won't fail on a case-only duplicate that existed before this change.

existsByUsername in UserService now ignores case as well.

Tests

New cases in AuthControllerTest and UserControllerTest:

  • login with a different case
  • the exact match wins when several case variants exist
  • refusal when several accounts match ignoring case and none exactly
  • duplicate checks on create and rename

AuthControllerTest (9) and UserControllerTest (56) pass locally.

🤖 Generated with Claude Code

Signing in found the account by exact username, so "Bob" could not log in
as "bob", and creating or renaming a user only rejected exact duplicates,
so "Bob" and "bob" could both exist.

- Login looks the user up ignoring case. An exact match wins, so accounts
  created before this change that differ only in case can each still sign
  in; several case-insensitive matches with no exact one are refused
  rather than guessed between.
- The token and log line carry the stored username, not the typed one,
  since everything downstream looks the user up by it.
- Creating a user, and renaming one, reject a username that already
  exists in any case. An edit that keeps the name does not trip over an
  old case-only duplicate.

Signed-off-by: Josh <ascetik@gmail.com>
@summitt
summitt merged commit 5f9c01e into main Nov 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant