Add Oudelaa dashboard API integration
فشلت بعض الفحوصات
Deploy To Ghaymah / deploy (push) Has been cancelled
فشلت بعض الفحوصات
Deploy To Ghaymah / deploy (push) Has been cancelled
هذا الالتزام موجود في:
37
oudelaa_dashboard/lib/permissions.ts
Normal file
37
oudelaa_dashboard/lib/permissions.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
export const SUPERADMIN_PERMISSIONS = {
|
||||
OVERVIEW_READ: "overview.read",
|
||||
ANALYTICS_READ: "analytics.read",
|
||||
USERS_READ: "users.read",
|
||||
USERS_MANAGE: "users.manage",
|
||||
CONTENT_MODERATE: "content.moderate",
|
||||
MARKETPLACE_MANAGE: "marketplace.manage",
|
||||
NOTIFICATIONS_READ: "notifications.read",
|
||||
AUDIT_READ: "audit.read",
|
||||
SETTINGS_READ: "settings.read",
|
||||
SETTINGS_WRITE: "settings.write",
|
||||
SESSIONS_MANAGE: "sessions.manage",
|
||||
OPS_READ: "ops.read",
|
||||
CASES_MANAGE: "cases.manage",
|
||||
} as const;
|
||||
|
||||
export type PermissionMatchMode = "all" | "any";
|
||||
|
||||
export function hasPermission(permissions: string[] | undefined, permission: string) {
|
||||
return (permissions ?? []).includes(permission);
|
||||
}
|
||||
|
||||
export function matchesPermissions(
|
||||
permissions: string[] | undefined,
|
||||
requiredPermissions: readonly string[],
|
||||
mode: PermissionMatchMode = "all",
|
||||
) {
|
||||
if (!requiredPermissions.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mode === "any") {
|
||||
return requiredPermissions.some((permission) => hasPermission(permissions, permission));
|
||||
}
|
||||
|
||||
return requiredPermissions.every((permission) => hasPermission(permissions, permission));
|
||||
}
|
||||
المرجع في مشكلة جديدة
حظر مستخدم