TK-FB(공장관리+신고)와 M-Project(부적합관리)를 3개 독립 시스템으로 분리하기 위한 전체 코드 구조 작성. - SSO 인증 서비스 (bcrypt + pbkdf2 이중 해시 지원) - System 1: 공장관리 (TK-FB 기반, 신고 코드 제거) - System 2: 신고 (TK-FB에서 workIssue 코드 추출) - System 3: 부적합관리 (M-Project 기반) - Gateway 포털 (path-based 라우팅) - 통합 docker-compose.yml 및 배포 스크립트 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
// /js/auth-check.js
|
|
import { isLoggedIn, getUser, clearAuthData } from './auth.js';
|
|
|
|
// 즉시 실행 함수로 스코프를 보호하고 로직을 실행
|
|
(function() {
|
|
if (!isLoggedIn()) {
|
|
console.log('🚨 인증되지 않은 사용자. 로그인 페이지로 이동합니다.');
|
|
clearAuthData(); // 만약을 위해 한번 더 정리
|
|
window.location.href = '/index.html';
|
|
return; // 이후 코드 실행 방지
|
|
}
|
|
|
|
const currentUser = getUser();
|
|
|
|
// 사용자 정보가 유효한지 확인 (토큰은 있지만 유저 정보가 깨졌을 경우)
|
|
if (!currentUser || !currentUser.username || !currentUser.role) {
|
|
console.error('🚨 사용자 정보가 유효하지 않습니다. 강제 로그아웃 처리합니다.');
|
|
clearAuthData();
|
|
window.location.href = '/index.html';
|
|
return;
|
|
}
|
|
|
|
console.log(`✅ ${currentUser.username}(${currentUser.role})님 인증 성공.`);
|
|
|
|
// 역할 기반 메뉴 제어 로직은 각 컴포넌트 로더(load-navbar.js 등)로 이전함.
|
|
// 전역 변수 할당(window.currentUser) 제거.
|
|
})(); |