From 017bbb44f32a5b95361e0e473bd68738bee70b2f Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Sat, 25 Oct 2025 12:19:14 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=88=98=EC=8B=A0=ED=95=A8=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=ED=8A=95=EA=B9=80=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0=20-=20=EA=B0=95=ED=99=94=EB=90=9C=20?= =?UTF-8?q?=EB=94=94=EB=B2=84=EA=B9=85=20=EB=B0=8F=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit πŸ”§ Root Cause Analysis: - μˆ˜μ‹ ν•¨ νŽ˜μ΄μ§€μ—μ„œ 3κ°€μ§€ κ²½μš°μ— 둜그인 ν™”λ©΄μœΌλ‘œ λ¦¬λ‹€μ΄λ ‰νŠΈ: 1. 토큰 μ—†μŒ (정상) 2. νŽ˜μ΄μ§€ μ ‘κ·Ό κΆŒν•œ μ—†μŒ (κ³Όλ„ν•œ 체크) 3. API 호좜 μ‹€νŒ¨ (κ³Όλ„ν•œ μ—λŸ¬ 처리) 🎯 Key Fixes: - updateStatistics() β†’ loadStatistics() ν•¨μˆ˜λͺ… 뢈일치 ν•΄κ²° - κ³Όλ„ν•œ μ—λŸ¬ 처리 κ°œμ„ : 401 μ—λŸ¬λ§Œ λ‘œκ·Έμ•„μ›ƒ, λ‚˜λ¨Έμ§€λŠ” κ²½κ³  ν›„ 계속 - κΆŒν•œ 체크 λ‘œμ§μ— 상세 디버깅 둜그 μΆ”κ°€ - μ΄ˆκΈ°ν™” κ³Όμ • 전체에 단계별 둜그 μΆ”κ°€ πŸ” Enhanced Debugging: - πŸš€ μˆ˜μ‹ ν•¨ μ΄ˆκΈ°ν™” μ‹œμž‘ - πŸ“‘ μ‚¬μš©μž 정보 API 호좜 μ‹œμž‘ - πŸ” μˆ˜μ‹ ν•¨ νŽ˜μ΄μ§€ μ ‘κ·Ό κΆŒν•œ 체크 μ‹œμž‘ - βœ…/❌ 각 단계별 성곡/μ‹€νŒ¨ 둜그 - ⚠️ 비정상 상황 감지 및 λŒ€μ‘ πŸ›‘οΈ Improved Error Handling: - 401/Unauthorized μ—λŸ¬: λ‘œκ·Έμ•„μ›ƒ 처리 (κΈ°μ‘΄) - 기타 μ—λŸ¬: μ‚¬μš©μž μ•Œλ¦Ό + 빈 μƒνƒœλ‘œ 계속 μ§„ν–‰ (μ‹ κ·œ) - 곡톡 헀더 fallback μ΄ˆκΈ°ν™” (localStorage 기반) - κΆŒν•œ ν•¨μˆ˜ λ―Έλ‘œλ“œ μ‹œ μŠ€ν‚΅ 처리 🎯 Expected Result: - μ‹€μ œ 인증 문제만 둜그인 ν™”λ©΄μœΌλ‘œ 이동 - λ„€νŠΈμ›Œν¬/데이터 λ‘œλ“œ μ‹€νŒ¨λŠ” κ²½κ³  ν›„ 계속 μ‚¬μš© κ°€λŠ₯ - μƒμ„Έν•œ 둜그둜 μ •ν™•ν•œ 원인 νŒŒμ•… κ°€λŠ₯ - μ‚¬μš©μž κ²½ν—˜ λŒ€ν­ κ°œμ„  --- frontend/issues-inbox.html | 58 ++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 9 deletions(-) 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); + } + } } }