From 54db9a42a9c74936e647bf5f64e00183ed9f063d Mon Sep 17 00:00:00 2001 From: Anwar Sadath <37188392+asadath1395@users.noreply.github.com> Date: Tue, 12 Mar 2024 22:09:01 +0530 Subject: [PATCH] fix: Create team events using admin token (#14044) * fix: Create team events using admin token * Revert `import {` to `import type {` --------- Co-authored-by: Alex van Andel --- .../event-types/_utils/checkTeamEventEditPermission.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/api/pages/api/event-types/_utils/checkTeamEventEditPermission.ts b/apps/api/pages/api/event-types/_utils/checkTeamEventEditPermission.ts index abcfc055f2..bc83c038b3 100644 --- a/apps/api/pages/api/event-types/_utils/checkTeamEventEditPermission.ts +++ b/apps/api/pages/api/event-types/_utils/checkTeamEventEditPermission.ts @@ -3,13 +3,17 @@ import type { z } from "zod"; import { HttpError } from "@calcom/lib/http-error"; -import type { schemaEventTypeBaseBodyParams } from "~/lib/validations/event-type"; +import type { schemaEventTypeCreateBodyParams } from "~/lib/validations/event-type"; export default async function checkTeamEventEditPermission( req: NextApiRequest, - body: Pick, "teamId"> + body: Pick, "teamId" | "userId"> ) { - const { prisma, userId } = req; + const { prisma, isAdmin } = req; + let userId = req.userId; + if (isAdmin && body.userId) { + userId = body.userId; + } if (body.teamId) { const membership = await prisma.membership.findFirst({ where: {