Fixed user create.

This commit is contained in:
Mike Cao 2025-02-21 17:47:59 -08:00
parent 4d0bd03b43
commit dc084b78a8
2 changed files with 3 additions and 4 deletions

View file

@ -10,7 +10,6 @@ export async function POST(request: Request) {
const schema = z.object({
username: z.string().max(255),
password: z.string(),
id: z.string().uuid(),
role: z.string().regex(/admin|user|view-only/i),
});
@ -24,7 +23,7 @@ export async function POST(request: Request) {
return unauthorized();
}
const { username, password, role, id } = body;
const { username, password, role } = body;
const existingUser = await getUserByUsername(username, { showDeleted: true });
@ -33,7 +32,7 @@ export async function POST(request: Request) {
}
const user = await createUser({
id: id || uuid(),
id: uuid(),
username,
password: hashPassword(password),
role: role ?? ROLES.user,