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 <[email protected]>
This commit is contained in:
Anwar SadathandAlex van Andel authored and GitHub committed 2024-03-12 16:39:01 +00:00
1 parent ce204d7a98
commit 54db9a42a9
1 file changed
+7 -3
@@ -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: {