forked from baron/baron-sso
adminfront 및 백엔드: 전 메뉴 및 탭 수준 ReBAC 기반 접근 제어(Admin Control) 기능 추가 구현 완료
This commit is contained in:
@@ -2,6 +2,19 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import { fetchTenant, fetchMe } from "../../../lib/adminApi";
|
||||
import { normalizeAdminRole } from "../../../lib/roles";
|
||||
|
||||
export type TenantPermissionKey =
|
||||
| "view"
|
||||
| "manage"
|
||||
| "manage_admins"
|
||||
| "view_profile"
|
||||
| "manage_profile"
|
||||
| "view_permissions"
|
||||
| "manage_permissions"
|
||||
| "view_organization"
|
||||
| "manage_organization"
|
||||
| "view_schema"
|
||||
| "manage_schema";
|
||||
|
||||
export function useTenantPermission(tenantId: string) {
|
||||
const { data: profile } = useQuery({
|
||||
queryKey: ["me"],
|
||||
@@ -14,7 +27,7 @@ export function useTenantPermission(tenantId: string) {
|
||||
enabled: !!tenantId,
|
||||
});
|
||||
|
||||
const hasPermission = (requiredRelation: "view" | "manage" | "manage_admins"): boolean => {
|
||||
const hasPermission = (requiredRelation: TenantPermissionKey): boolean => {
|
||||
// Super Admin always has full bypass access
|
||||
if (normalizeAdminRole(profile?.role) === "super_admin") {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user