fix: make signin email case-insensitive

Closes #3981
This commit is contained in:
Alejandro Gispert committed 2026-02-22 07:18:00 +01:00
1 parent 2260520ae5
commit 2ab58700b2
3 files changed
+61 -39

No files matched your search

+13 -11
View File
@@ -1,11 +1,11 @@
import { z } from 'zod';
import { ROLES } from '@/lib/constants';
import { uuid } from '@/lib/crypto';
import { hashPassword } from '@/lib/password';
import { parseRequest } from '@/lib/request';
import { badRequest, json, unauthorized } from '@/lib/response';
import { canCreateUser } from '@/permissions';
import { createUser, getUserByUsername } from '@/queries/prisma';
import { z } from "zod";
import { ROLES } from "@/lib/constants";
import { uuid } from "@/lib/crypto";
import { hashPassword } from "@/lib/password";
import { parseRequest } from "@/lib/request";
import { badRequest, json, unauthorized } from "@/lib/response";
import { canCreateUser } from "@/permissions";
import { createUser, getUserByUsername } from "@/queries/prisma";
export async function POST(request: Request) {
const schema = z.object({
@@ -27,15 +27,17 @@ export async function POST(request: Request) {
const { id, username, password, role } = body;
const existingUser = await getUserByUsername(username, { showDeleted: true });
const existingUser = await getUserByUsername(username, {
showDeleted: true,
});
if (existingUser) {
return badRequest({ message: 'User already exists' });
return badRequest({ message: "User already exists" });
}
const user = await createUser({
id: id || uuid(),
username,
username: username.toLowerCase(),
password: hashPassword(password),
role: role ?? ROLES.user,
});