mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 13:47:15 +01:00
fix response error return type
This commit is contained in:
parent
460200dfef
commit
8083482ba8
12 changed files with 23 additions and 25 deletions
|
|
@ -2,7 +2,7 @@ import { z } from 'zod';
|
|||
import { canUpdateUser, canViewUser, canDeleteUser } from '@/permissions';
|
||||
import { getUser, getUserByUsername, updateUser, deleteUser } from '@/queries';
|
||||
import { json, unauthorized, badRequest, ok } from '@/lib/response';
|
||||
import { hashPassword } from '@/lib/auth';
|
||||
import { hashPassword } from '@/lib/password';
|
||||
import { parseRequest } from '@/lib/request';
|
||||
import { userRoleParam } from '@/lib/schema';
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ export async function POST(request: Request, { params }: { params: Promise<{ use
|
|||
const user = await getUserByUsername(username);
|
||||
|
||||
if (user) {
|
||||
return badRequest('User already exists');
|
||||
return badRequest({ message: 'User already exists' });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ export async function DELETE(
|
|||
}
|
||||
|
||||
if (userId === auth.user.id) {
|
||||
return badRequest('You cannot delete yourself.');
|
||||
return badRequest({ message: 'You cannot delete yourself.' });
|
||||
}
|
||||
|
||||
await deleteUser(userId);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { z } from 'zod';
|
||||
import { hashPassword } from '@/lib/auth';
|
||||
import { hashPassword } from '@/lib/password';
|
||||
import { canCreateUser } from '@/permissions';
|
||||
import { ROLES } from '@/lib/constants';
|
||||
import { uuid } from '@/lib/crypto';
|
||||
|
|
@ -30,7 +30,7 @@ export async function POST(request: Request) {
|
|||
const existingUser = await getUserByUsername(username, { showDeleted: true });
|
||||
|
||||
if (existingUser) {
|
||||
return badRequest('User already exists');
|
||||
return badRequest({ message: 'User already exists' });
|
||||
}
|
||||
|
||||
const user = await createUser({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue