Fixed user create.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "umami",
|
"name": "umami",
|
||||||
"version": "2.16.0",
|
"version": "2.16.1",
|
||||||
"description": "A simple, fast, privacy-focused alternative to Google Analytics.",
|
"description": "A simple, fast, privacy-focused alternative to Google Analytics.",
|
||||||
"author": "Umami Software, Inc. <hello@umami.is>",
|
"author": "Umami Software, Inc. <hello@umami.is>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ export async function POST(request: Request) {
|
|||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
username: z.string().max(255),
|
username: z.string().max(255),
|
||||||
password: z.string(),
|
password: z.string(),
|
||||||
id: z.string().uuid(),
|
|
||||||
role: z.string().regex(/admin|user|view-only/i),
|
role: z.string().regex(/admin|user|view-only/i),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ export async function POST(request: Request) {
|
|||||||
return unauthorized();
|
return unauthorized();
|
||||||
}
|
}
|
||||||
|
|
||||||
const { username, password, role, id } = body;
|
const { username, password, role } = body;
|
||||||
|
|
||||||
const existingUser = await getUserByUsername(username, { showDeleted: true });
|
const existingUser = await getUserByUsername(username, { showDeleted: true });
|
||||||
|
|
||||||
@@ -33,7 +32,7 @@ export async function POST(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const user = await createUser({
|
const user = await createUser({
|
||||||
id: id || uuid(),
|
id: uuid(),
|
||||||
username,
|
username,
|
||||||
password: hashPassword(password),
|
password: hashPassword(password),
|
||||||
role: role ?? ROLES.user,
|
role: role ?? ROLES.user,
|
||||||
|
|||||||
Reference in New Issue
Block a user