Merge pull request #4142 from nielskaspers/fix/issue-3981-case-insensitive-login

fix: make username login case-insensitive
This commit is contained in:
Mike Cao
2026-05-14 23:49:04 -04:00
committed by GitHub
3 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -63,14 +63,14 @@ export async function POST(request: Request, { params }: { params: Promise<{ use
}
if (username && auth.user.isAdmin) {
data.username = username;
data.username = username.toLowerCase();
}
// Check when username changes
if (data.username && user.username !== data.username) {
const user = await getUserByUsername(username);
const existingUser = await getUserByUsername(data.username);
if (user) {
if (existingUser && existingUser.id !== userId) {
return badRequest({ message: 'User already exists' });
}
}
+1 -1
View File
@@ -36,7 +36,7 @@ export async function POST(request: Request) {
const user = await createUser({
id: id || uuid(),
username,
username: username.toLowerCase(),
password: hashPassword(password),
role: role ?? ROLES.user,
});
+1 -1
View File
@@ -46,7 +46,7 @@ export async function getUser(userId: string, options: GetUserOptions = {}) {
}
export async function getUserByUsername(username: string, options: GetUserOptions = {}) {
return findUser({ where: { username } }, options);
return findUser({ where: { username: username.toLowerCase() } }, options);
}
export async function getUsers(criteria: UserFindManyArgs, filters: QueryFilters = {}) {