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 <me@alexvanandel.com>
This commit is contained in:
Anwar Sadath
2024-03-12 16:39:01 +00:00
committed by GitHub
co-authored by Alex van Andel
parent ce204d7a98
commit 54db9a42a9
@@ -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: {