Patching bodyUserId requests
parent
b30995456c
commit
7617cd43e1
|
@ -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) throw new HttpError({ statusCode: 403, message: `ADMIN required for userId` });
|
||||||
|
|
||||||
if (isAdmin && bodyUserId) {
|
if (isAdmin && bodyUserId) {
|
||||||
const where: Prisma.UserWhereInput = { id: userId };
|
const where: Prisma.UserWhereInput = { id: bodyUserId };
|
||||||
await prisma.user.findFirstOrThrow({ where });
|
await prisma.user.findFirstOrThrow({ where });
|
||||||
args.data.userId = userId;
|
args.data.userId = bodyUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await prisma.selectedCalendar.update(args);
|
const result = await prisma.selectedCalendar.update(args);
|
||||||
|
|
|
@ -46,7 +46,7 @@ async function postHandler(req: NextApiRequest) {
|
||||||
if (isAdmin && bodyUserId) {
|
if (isAdmin && bodyUserId) {
|
||||||
const where: Prisma.UserWhereInput = { id: bodyUserId };
|
const where: Prisma.UserWhereInput = { id: bodyUserId };
|
||||||
await prisma.user.findFirstOrThrow({ where });
|
await prisma.user.findFirstOrThrow({ where });
|
||||||
args.data.userId = userId;
|
args.data.userId = bodyUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await prisma.selectedCalendar.create(args);
|
const data = await prisma.selectedCalendar.create(args);
|
||||||
|
|
|
@ -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) throw new HttpError({ statusCode: 403, message: `ADMIN required for userId` });
|
||||||
|
|
||||||
if (isAdmin && bodyUserId) {
|
if (isAdmin && bodyUserId) {
|
||||||
const where: Prisma.UserWhereInput = { id: userId };
|
const where: Prisma.UserWhereInput = { id: bodyUserId };
|
||||||
await prisma.user.findFirstOrThrow({ where });
|
await prisma.user.findFirstOrThrow({ where });
|
||||||
args.data.userId = userId;
|
args.data.userId = bodyUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await prisma.webhook.create(args);
|
const data = await prisma.webhook.create(args);
|
||||||
|
|
Loading…
Reference in New Issue