debug: AuthManager 및 DOM 상태 디버깅 로그 추가

🔍 Debug Logs Added:
- AuthManager.checkAuth() 상세 상태 로그
- localStorage 토큰/사용자 정보 존재 여부 확인
- currentUser 전역 변수 업데이트 로그
- DOM 요소 존재 여부 및 화면 전환 상태 확인

🎯 Issue Analysis:
- AuthManager 정상 작동 확인됨 ( 캐시된 인증 정보 사용)
- 공통 헤더 초기화 성공
- currentUser undefined 문제 → 전역 변수 동기화 이슈
- 로그인 창 보임 → DOM 조작 실패 가능성

🔧 Enhanced Debugging:
- 🖥️ 화면 전환 시작/완료 로그
- loginScreen/mainScreen 요소 존재 확인
- CSS 클래스 적용 상태 확인
- 화면 전환 실패 시 에러 로그

Next Step: 콘솔 로그 확인하여 정확한 실패 지점 파악
This commit is contained in:
Hyungi Ahn
2025-10-25 12:32:33 +09:00
parent c69e16a20a
commit f9160f9bd1
2 changed files with 28 additions and 4 deletions

View File

@@ -555,6 +555,7 @@
if (user) {
currentUser = user;
console.log('✅ currentUser 전역 변수 업데이트:', currentUser.username);
// 공통 헤더 초기화
console.log('🔧 공통 헤더 초기화 시작:', user.username);
@@ -582,8 +583,22 @@
}, 500);
// 메인 화면 표시
document.getElementById('loginScreen').classList.add('hidden');
document.getElementById('mainScreen').classList.remove('hidden');
console.log('🖥️ 화면 전환 시작');
const loginScreen = document.getElementById('loginScreen');
const mainScreen = document.getElementById('mainScreen');
console.log('loginScreen 요소:', !!loginScreen);
console.log('mainScreen 요소:', !!mainScreen);
if (loginScreen && mainScreen) {
loginScreen.classList.add('hidden');
mainScreen.classList.remove('hidden');
console.log('✅ 메인 화면으로 전환 완료');
console.log('loginScreen hidden:', loginScreen.classList.contains('hidden'));
console.log('mainScreen hidden:', mainScreen.classList.contains('hidden'));
} else {
console.error('❌ 화면 요소를 찾을 수 없음');
}
// 데이터 로드
await loadProjects();

View File

@@ -41,6 +41,10 @@ class AuthManager {
const token = localStorage.getItem('access_token');
const userStr = localStorage.getItem('currentUser');
console.log('🔍 localStorage 확인:');
console.log('- 토큰 존재:', !!token);
console.log('- 사용자 정보 존재:', !!userStr);
if (token && userStr) {
try {
this.currentUser = JSON.parse(userStr);
@@ -51,6 +55,8 @@ class AuthManager {
console.error('❌ 사용자 정보 복원 실패:', error);
this.clearAuth();
}
} else {
console.log('❌ 토큰 또는 사용자 정보 없음 - 로그인 필요');
}
}
@@ -69,11 +75,13 @@ class AuthManager {
* 인증 상태 확인 (필요시에만 API 호출)
*/
async checkAuth() {
console.log('🔍 인증 상태 확인 시작');
console.log('🔍 AuthManager.checkAuth() 호출됨');
console.log('- 현재 인증 상태:', this.isAuthenticated);
console.log('- 현재 사용자:', this.currentUser?.username || 'null');
const token = localStorage.getItem('access_token');
if (!token) {
console.log('❌ 토큰 없음');
console.log('❌ 토큰 없음 - 인증 실패');
this.clearAuth();
return null;
}
@@ -85,6 +93,7 @@ class AuthManager {
}
// API 호출이 필요한 경우
console.log('🔄 API 호출 필요 - refreshAuth 실행');
return await this.refreshAuth();
}