Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
fix: Admin Logic for event-type API endpoint (calcom#12482)
Browse files Browse the repository at this point in the history
* Fix Admin logic

* chore: fix prettier

---------

Co-authored-by: Udit Takkar <[email protected]>
  • Loading branch information
alishaz-polymath and Udit-takkar authored Nov 22, 2023
1 parent 48dde24 commit 16c5b07
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/api/pages/api/event-types/_post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,13 @@ async function checkPermissions(req: NextApiRequest) {
statusCode: 401,
message: "ADMIN required for `userId`",
});
if (!isAdmin && body.teamId)
throw new HttpError({
statusCode: 401,
message: "ADMIN required for `teamId`",
});
/* Admin users are required to pass in a userId or teamId */
if (isAdmin && (!body.userId || !body.teamId))
if (isAdmin && !body.userId && !body.teamId)
throw new HttpError({ statusCode: 400, message: "`userId` or `teamId` required" });
}

Expand Down

0 comments on commit 16c5b07

Please sign in to comment.