Allow non-admin team members also to reroute (#17234)

This commit is contained in:
Hariom Balhara authored and GitHub committed 2024-10-22 13:46:30 +05:30
1 parent 2f4dd328c3
commit 86af6bd626
4 files changed
+35 -11

No files matched your search

+15
View File
@@ -3,8 +3,11 @@ import { MembershipRole } from "@calcom/prisma/enums";
export const enum ENTITY_PERMISSION_LEVEL {
NONE,
// It is owned by user and user has write access to it
USER_ONLY_WRITE,
// All members of the team has access to it and user has read access to it
TEAM_READ_ONLY,
// All members of the team has access to it and user has write access to it
TEAM_WRITE,
}
@@ -19,6 +22,18 @@ export function canEditEntity(
);
}
export function canAccessEntity(
entity: Parameters<typeof getEntityPermissionLevel>[0],
userId: Parameters<typeof getEntityPermissionLevel>[1]
) {
const permissionLevel = getEntityPermissionLevel(entity, userId);
return (
permissionLevel === ENTITY_PERMISSION_LEVEL.TEAM_WRITE ||
permissionLevel === ENTITY_PERMISSION_LEVEL.USER_ONLY_WRITE ||
permissionLevel === ENTITY_PERMISSION_LEVEL.TEAM_READ_ONLY
);
}
export function getEntityPermissionLevel(
entity: {
userId: number | null;