1
0
forked from baron/baron-sso

관리자 권한 판별 로직 보완으로 메뉴/접근 제어 일치화

This commit is contained in:
2026-03-04 13:15:28 +09:00
parent 1b4b5d433f
commit 0f8b19a9b1
3 changed files with 88 additions and 17 deletions

25
devfront/src/lib/role.ts Normal file
View File

@@ -0,0 +1,25 @@
export function normalizeRole(rawRole: unknown): string {
if (typeof rawRole !== "string") return "";
const role = rawRole.trim().toLowerCase();
if (role === "tenant_member") return "user";
if (role === "admin") return "tenant_admin";
if (role === "superadmin") return "super_admin";
if (role === "tenantadmin") return "tenant_admin";
if (role === "rpadmin") return "rp_admin";
return role;
}
export function resolveProfileRole(profile: Record<string, unknown> | undefined) {
if (!profile) return "";
const candidates = [
profile.role,
profile.grade,
profile["custom:role"],
profile["custom:grade"],
];
for (const candidate of candidates) {
const normalized = normalizeRole(candidate);
if (normalized) return normalized;
}
return "";
}