forked from baron/baron-sso
관리자 권한 판별 로직 보완으로 메뉴/접근 제어 일치화
This commit is contained in:
25
devfront/src/lib/role.ts
Normal file
25
devfront/src/lib/role.ts
Normal 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 "";
|
||||
}
|
||||
Reference in New Issue
Block a user