fix(tkuser): 권한 기반 탭 자동 라우팅 — 제한 사용자 진입 시 첫 허용 탭 표시
users 권한 없는 일반 사용자가 빈 화면(비밀번호 변경 폼만) 보이던 문제 수정. 허용된 탭으로 자동 전환하고, 탭 버튼에 data-tab 속성 추가하여 프로그래밍적 switchTab() 호출 시 active 버튼도 정확히 갱신되도록 개선. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -128,9 +128,6 @@ 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`);
|
||||
@@ -154,10 +151,8 @@ async function init() {
|
||||
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];
|
||||
const tabName = btn.getAttribute('data-tab');
|
||||
if (tabName) {
|
||||
// permissions 탭은 admin 전용
|
||||
if (tabName === 'permissions') {
|
||||
btn.style.display = 'none';
|
||||
@@ -167,12 +162,20 @@ async function init() {
|
||||
}
|
||||
});
|
||||
|
||||
// tkuser.users 권한 시 adminSection 표시
|
||||
// tkuser.users 권한 시 adminSection + passwordChangeSection 표시
|
||||
if (currentUserAllowedTabs.has('users')) {
|
||||
document.getElementById('adminSection').classList.remove('hidden');
|
||||
document.getElementById('passwordChangeSection').classList.remove('hidden');
|
||||
await loadDepartmentsCache();
|
||||
await loadUsers();
|
||||
} else {
|
||||
// users 권한 없음 → tab-users 숨기고 첫 허용 탭으로 자동 전환
|
||||
document.getElementById('tab-users').classList.add('hidden');
|
||||
switchTab([...currentUserAllowedTabs][0]);
|
||||
}
|
||||
} else {
|
||||
// 아무 권한 없음 → 비밀번호 변경만 표시 (fallback)
|
||||
document.getElementById('passwordChangeSection').classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
@@ -194,7 +197,7 @@ async function init() {
|
||||
'consumables','notificationRecipients'];
|
||||
const urlTab = new URLSearchParams(location.search).get('tab');
|
||||
if (urlTab && ALLOWED_TABS.includes(urlTab)) {
|
||||
const tabBtn = document.querySelector(`.tab-btn[onclick*="switchTab('${urlTab}')"]`);
|
||||
const tabBtn = document.querySelector(`.tab-btn[data-tab="${urlTab}"]`);
|
||||
if (tabBtn && tabBtn.style.display !== 'none') {
|
||||
tabBtn.click();
|
||||
const url = new URL(location);
|
||||
|
||||
Reference in New Issue
Block a user