Scheduling infrastructure for absolutely everyone.
fix: Create team events using admin token (#14044)
Anwar Sadath54db9a42a9c7
diff --git a/apps/api/pages/api/event-types/_utils/checkTeamEventEditPermission.ts b/apps/api/pages/api/event-types/_utils/checkTeamEventEditPermission.tsindex abcfc055f2d..bc83c038b32 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<z.infer<typeof schemaEventTypeBaseBodyParams>, "teamId">+ body: Pick<z.infer<typeof schemaEventTypeCreateBodyParams>, "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: {