From 7617cd43e1d0cb4b01f6be1dd29ba1c881a2d3a1 Mon Sep 17 00:00:00 2001 From: zomars Date: Fri, 21 Oct 2022 12:55:15 -0600 Subject: [PATCH] Patching bodyUserId requests --- pages/api/selected-calendars/[id]/_patch.ts | 4 ++-- pages/api/selected-calendars/_post.ts | 2 +- pages/api/webhooks/_post.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pages/api/selected-calendars/[id]/_patch.ts b/pages/api/selected-calendars/[id]/_patch.ts index 064bee1dbc..ae78b67fc6 100644 --- a/pages/api/selected-calendars/[id]/_patch.ts +++ b/pages/api/selected-calendars/[id]/_patch.ts @@ -54,9 +54,9 @@ export async function patchHandler(req: NextApiRequest) { if (!isAdmin && bodyUserId) throw new HttpError({ statusCode: 403, message: `ADMIN required for userId` }); if (isAdmin && bodyUserId) { - const where: Prisma.UserWhereInput = { id: userId }; + const where: Prisma.UserWhereInput = { id: bodyUserId }; await prisma.user.findFirstOrThrow({ where }); - args.data.userId = userId; + args.data.userId = bodyUserId; } const result = await prisma.selectedCalendar.update(args); diff --git a/pages/api/selected-calendars/_post.ts b/pages/api/selected-calendars/_post.ts index 2118c5348f..08ca7e4e41 100644 --- a/pages/api/selected-calendars/_post.ts +++ b/pages/api/selected-calendars/_post.ts @@ -46,7 +46,7 @@ async function postHandler(req: NextApiRequest) { if (isAdmin && bodyUserId) { const where: Prisma.UserWhereInput = { id: bodyUserId }; await prisma.user.findFirstOrThrow({ where }); - args.data.userId = userId; + args.data.userId = bodyUserId; } const data = await prisma.selectedCalendar.create(args); diff --git a/pages/api/webhooks/_post.ts b/pages/api/webhooks/_post.ts index dd7f97dd87..f87b8ffe57 100644 --- a/pages/api/webhooks/_post.ts +++ b/pages/api/webhooks/_post.ts @@ -43,9 +43,9 @@ async function postHandler(req: NextApiRequest) { if (!isAdmin && bodyUserId) throw new HttpError({ statusCode: 403, message: `ADMIN required for userId` }); if (isAdmin && bodyUserId) { - const where: Prisma.UserWhereInput = { id: userId }; + const where: Prisma.UserWhereInput = { id: bodyUserId }; await prisma.user.findFirstOrThrow({ where }); - args.data.userId = userId; + args.data.userId = bodyUserId; } const data = await prisma.webhook.create(args);