Prevent team members from creating events (#3498)

* Delete CreateEventTypeBtn.tsx

* Adding Permission to creation router

* Disable button if membership role is member

* Fix linting error

* Update explicit role selection

Co-authored-by: Omar López <[email protected]>

* Type fix

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Omar López <[email protected]>
This commit is contained in:
authored and GitHub committed 2022-07-26 18:25:42 +00:00
1 parent 7a306900ab
commit 3bdf4a84f8
2 files changed
+92 -36

No files matched your search

@@ -139,7 +139,7 @@ export const eventTypesRouter = createProtectedRouter()
},
});
if (!hasMembership) {
if (!hasMembership?.role || !["ADMIN", "OWNER"].includes(hasMembership.role)) {
console.warn(`User ${userId} does not have permission to create this new event type`);
throw new TRPCError({ code: "UNAUTHORIZED" });
}