feat(tkuser): 통합 관리 탭별 권한 시스템 추가
- DEFAULT_PAGES에 tkuser 시스템 10개 페이지 권한 정의 추가 - 권한 관리 UI에 tkuser 섹션 추가 (개인/부서 권한 모두) - 비admin 사용자 로그인 시 effective-permissions 기반 탭 표시 제어 - switchTab()에 권한 guard 추가하여 비허용 탭 접근 차단 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -80,6 +80,8 @@ function doLogout() {
|
||||
|
||||
/* ===== State ===== */
|
||||
let currentUser = null;
|
||||
// null = admin(제한없음), Set = 허용된 탭만
|
||||
let currentUserAllowedTabs = null;
|
||||
|
||||
/* ===== Init ===== */
|
||||
async function init() {
|
||||
@@ -124,7 +126,57 @@ async function init() {
|
||||
await loadDepartmentsCache();
|
||||
await loadUsers();
|
||||
} else {
|
||||
// 비밀번호 변경은 항상 표시
|
||||
document.getElementById('passwordChangeSection').classList.remove('hidden');
|
||||
|
||||
// tkuser 탭별 권한 확인
|
||||
try {
|
||||
const result = await api(`/permissions/users/${currentUser.id}/effective-permissions`);
|
||||
if (result.permissions) {
|
||||
// TKUSER_PAGES에서 TAB_PERM_MAP 동적 생성
|
||||
const TAB_PERM_MAP = {};
|
||||
if (typeof TKUSER_PAGES !== 'undefined') {
|
||||
Object.values(TKUSER_PAGES).flat().forEach(p => { TAB_PERM_MAP[p.key] = p.tab; });
|
||||
}
|
||||
|
||||
currentUserAllowedTabs = new Set();
|
||||
for (const [permKey, tabName] of Object.entries(TAB_PERM_MAP)) {
|
||||
const info = result.permissions[permKey];
|
||||
if (info && info.can_access) {
|
||||
currentUserAllowedTabs.add(tabName);
|
||||
}
|
||||
}
|
||||
|
||||
// 허용된 탭이 있으면 tabNav 표시
|
||||
if (currentUserAllowedTabs.size > 0) {
|
||||
document.getElementById('tabNav').classList.remove('hidden');
|
||||
// 비허용 탭 버튼 숨김
|
||||
document.querySelectorAll('.tab-btn').forEach(btn => {
|
||||
const onclick = btn.getAttribute('onclick') || '';
|
||||
const match = onclick.match(/switchTab\('(\w+)'\)/);
|
||||
if (match) {
|
||||
const tabName = match[1];
|
||||
// permissions 탭은 admin 전용
|
||||
if (tabName === 'permissions') {
|
||||
btn.style.display = 'none';
|
||||
} else if (!currentUserAllowedTabs.has(tabName)) {
|
||||
btn.style.display = 'none';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// tkuser.users 권한 시 adminSection 표시
|
||||
if (currentUserAllowedTabs.has('users')) {
|
||||
document.getElementById('adminSection').classList.remove('hidden');
|
||||
await loadDepartmentsCache();
|
||||
await loadUsers();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
console.error('[tkuser] 권한 확인 실패:', e);
|
||||
showToast('권한 정보를 불러올 수 없습니다', 'error');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[tkuser] init 오류:', e);
|
||||
|
||||
Reference in New Issue
Block a user