Formatting

This commit is contained in:
zomars committed 2022-10-15 10:54:22 -06:00
1 parent 00bd908916
commit 07b011424f
3 files changed
+3 -6

No files matched your search

+1 -2
View File
@@ -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" });
+1 -2
View File
@@ -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 };
+1 -2
View File
@@ -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({