Cleared of the stuff the EnCoach team wanted changed

This commit is contained in:
Tiago Ribeiro
2024-10-28 14:40:26 +00:00
parent 0becd295b0
commit fa0c502467
34 changed files with 166 additions and 107 deletions

View File

@@ -42,6 +42,13 @@ export function findAllowedEntities(user: User, entities: EntityWithRoles[], per
return allowedEntities
}
export function findAllowedEntitiesSomePermissions(user: User, entities: EntityWithRoles[], permissions: RolePermission[]) {
if (["admin", "developer"].includes(user?.type)) return entities
const allowedEntities = entities.filter((e) => permissions.some((p) => doesEntityAllow(user, e, p)))
return allowedEntities
}
export function doesEntityAllow(user: User, entity: EntityWithRoles, permission: RolePermission) {
if (["admin", "developer"].includes(user?.type)) return true