feat(rbac): add roles and permissions
This commit is contained in:
parent
86a32a942c
commit
694b7bd09a
37 changed files with 2682 additions and 218 deletions
19
frontend/athena/lib/permissions.ts
Normal file
19
frontend/athena/lib/permissions.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import type { CurrentUser, PermissionName } from "@/types/rbac";
|
||||
|
||||
export function hasPermission(user: CurrentUser | null | undefined, permission: PermissionName) {
|
||||
return Boolean(user?.permissions.includes(permission));
|
||||
}
|
||||
|
||||
export function hasAnyPermission(
|
||||
user: CurrentUser | null | undefined,
|
||||
permissions: PermissionName[],
|
||||
) {
|
||||
return permissions.some((permission) => hasPermission(user, permission));
|
||||
}
|
||||
|
||||
export function hasAllPermissions(
|
||||
user: CurrentUser | null | undefined,
|
||||
permissions: PermissionName[],
|
||||
) {
|
||||
return permissions.every((permission) => hasPermission(user, permission));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue