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: {