diff --git a/frontend/issues-inbox.html b/frontend/issues-inbox.html
index 1c59a4a..6f4def5 100644
--- a/frontend/issues-inbox.html
+++ b/frontend/issues-inbox.html
@@ -386,14 +386,21 @@
// API 로드 후 초기화 함수
async function initializeInbox() {
+ console.log('🚀 수신함 초기화 시작');
+
const token = localStorage.getItem('access_token');
+ console.log('토큰 존재:', !!token);
+
if (!token) {
+ console.log('❌ 토큰 없음 - 로그인 페이지로 이동');
window.location.href = '/index.html';
return;
}
try {
+ console.log('📡 사용자 정보 API 호출 시작');
const user = await AuthAPI.getCurrentUser();
+ console.log('✅ 사용자 정보 로드 성공:', user);
currentUser = user;
localStorage.setItem('currentUser', JSON.stringify(user));
@@ -402,23 +409,56 @@
// 페이지 접근 권한 체크
setTimeout(() => {
- if (!canAccessPage('issues_inbox')) {
- alert('수신함 페이지에 접근할 권한이 없습니다.');
- window.location.href = '/index.html';
- return;
+ console.log('🔐 수신함 페이지 접근 권한 체크 시작');
+ console.log('현재 사용자:', currentUser);
+ console.log('canAccessPage 함수 존재:', typeof canAccessPage);
+
+ if (typeof canAccessPage === 'function') {
+ const hasAccess = canAccessPage('issues_inbox');
+ console.log('수신함 접근 권한:', hasAccess);
+
+ if (!hasAccess) {
+ console.log('❌ 수신함 접근 권한 없음 - 메인 페이지로 이동');
+ alert('수신함 페이지에 접근할 권한이 없습니다.');
+ window.location.href = '/index.html';
+ return;
+ } else {
+ console.log('✅ 수신함 접근 권한 확인됨');
+ }
+ } else {
+ console.log('⚠️ canAccessPage 함수가 로드되지 않음 - 권한 체크 스킵');
}
}, 500);
// 데이터 로드
await loadProjects();
await loadIssues();
- updateStatistics();
+ // loadIssues()에서 이미 loadStatistics() 호출함
} catch (error) {
- console.error('인증 실패:', error);
- localStorage.removeItem('access_token');
- localStorage.removeItem('currentUser');
- window.location.href = '/index.html';
+ console.error('수신함 초기화 실패:', error);
+
+ // 401 Unauthorized 에러인 경우만 로그아웃 처리
+ if (error.message && (error.message.includes('401') || error.message.includes('Unauthorized') || error.message.includes('Not authenticated'))) {
+ console.log('🔐 인증 토큰 만료 - 로그아웃 처리');
+ localStorage.removeItem('access_token');
+ localStorage.removeItem('currentUser');
+ window.location.href = '/index.html';
+ } else {
+ // 다른 에러는 사용자에게 알리고 계속 진행
+ console.log('⚠️ 데이터 로드 실패 - 빈 상태로 표시');
+ alert('일부 데이터를 불러오는데 실패했습니다. 새로고침 후 다시 시도해주세요.');
+
+ // 공통 헤더만이라도 초기화
+ try {
+ const user = JSON.parse(localStorage.getItem('currentUser') || '{}');
+ if (user.id) {
+ await window.commonHeader.init(user, 'issues_inbox');
+ }
+ } catch (headerError) {
+ console.error('공통 헤더 초기화 실패:', headerError);
+ }
+ }
}
}