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:
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" });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user