fix(nav): 사이드바 메뉴를 DB 권한(accessibleKeys) 기반으로 필터링
기존: non-admin 페이지는 무조건 표시 (publicPageKeys 개념) 변경: accessibleKeys에 포함된 페이지만 표시 (대시보드 그리드와 동일 기준) - publicPageKeys 로직 제거, accessibleKeys 단일 기준 통합 - external 링크(부적합, 휴가 신청 등)는 항상 표시 - dashboard, profile.* 페이지는 전체 공개 유지 - tkfb-core.js 캐시 버스팅 v=2026040103 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -202,8 +202,7 @@ function renderNavbar(accessibleKeys) {
|
||||
const visibleItems = entry.items.filter(item => {
|
||||
if (item.admin && !isAdmin) return false;
|
||||
if (isAdmin) return true;
|
||||
// NAV_MENU에 admin 아닌 항목은 공개 (publicPageKeys 대응)
|
||||
if (!item.admin) return true;
|
||||
if (item.external) return true;
|
||||
return accessibleKeys.includes(item.key);
|
||||
});
|
||||
|
||||
@@ -283,16 +282,13 @@ async function initAuth() {
|
||||
let accessibleKeys = [];
|
||||
if (!isAdmin) {
|
||||
accessibleKeys = await _fetchPageAccess(currentUser.id);
|
||||
// NAV_MENU에서 admin/restricted가 아닌 페이지는 모든 인증 사용자에게 공개
|
||||
const publicPageKeys = NAV_MENU.flatMap(entry => {
|
||||
if (!entry.items) return entry.key ? [entry.key] : [];
|
||||
if (entry.admin) return [];
|
||||
return entry.items.filter(item => !item.admin && !item.restricted).map(item => item.key);
|
||||
});
|
||||
// 현재 페이지 접근 권한 확인
|
||||
if (accessibleKeys.length === 0) {
|
||||
console.warn('[PageAccess] 접근 가능 페이지가 없거나 권한 조회 실패');
|
||||
}
|
||||
// 현재 페이지 접근 권한 확인 (dashboard, profile은 전체 공개)
|
||||
const pageKey = _getCurrentPageKey();
|
||||
if (pageKey && pageKey !== 'dashboard' && !pageKey.startsWith('profile.')) {
|
||||
if (!publicPageKeys.includes(pageKey) && !accessibleKeys.includes(pageKey)) {
|
||||
if (!accessibleKeys.includes(pageKey)) {
|
||||
alert('이 페이지에 접근할 권한이 없습니다.');
|
||||
location.href = '/pages/dashboard-new.html';
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user