Formatting
This commit is contained in:
1 parent
00bd908916
commit
07b011424f
3 files changed
+3
-6
No files matched your search
@@ -33,8 +33,7 @@ export async function deleteHandler(req: NextApiRequest) {
|
||||
const { prisma, isAdmin } = req;
|
||||
const query = schemaQueryUserId.parse(req.query);
|
||||
// Here we only check for ownership of the user if the user is not admin, otherwise we let ADMIN's edit any user
|
||||
if (!isAdmin && query.userId !== req.userId)
|
||||
throw new HttpError({ statusCode: 403, message: "Forbidden" });
|
||||
if (!isAdmin && query.userId !== req.userId) throw new HttpError({ statusCode: 403, message: "Forbidden" });
|
||||
|
||||
const user = await prisma.user.findUnique({ where: { id: query.userId } });
|
||||
if (!user) throw new HttpError({ statusCode: 404, message: "User not found" });
|
||||
|
||||
@@ -35,8 +35,7 @@ export async function getHandler(req: NextApiRequest) {
|
||||
|
||||
const query = schemaQueryUserId.parse(req.query);
|
||||
// Here we only check for ownership of the user if the user is not admin, otherwise we let ADMIN's edit any user
|
||||
if (!isAdmin && query.userId !== req.userId)
|
||||
throw new HttpError({ statusCode: 403, message: "Forbidden" });
|
||||
if (!isAdmin && query.userId !== req.userId) throw new HttpError({ statusCode: 403, message: "Forbidden" });
|
||||
const data = await prisma.user.findUnique({ where: { id: query.userId } });
|
||||
const user = schemaUserReadPublic.parse(data);
|
||||
return { user };
|
||||
|
||||
@@ -55,8 +55,7 @@ export async function patchHandler(req: NextApiRequest) {
|
||||
const { prisma, isAdmin } = req;
|
||||
const query = schemaQueryUserId.parse(req.query);
|
||||
// Here we only check for ownership of the user if the user is not admin, otherwise we let ADMIN's edit any user
|
||||
if (!isAdmin && query.userId !== req.userId)
|
||||
throw new HttpError({ statusCode: 403, message: "Forbidden" });
|
||||
if (!isAdmin && query.userId !== req.userId) throw new HttpError({ statusCode: 403, message: "Forbidden" });
|
||||
|
||||
const body = schemaUserEditBodyParams.parse(req.body);
|
||||
const userSchedules = await prisma.schedule.findMany({
|
||||
|
||||
Reference in new issue
Block a user