feat: 관리자 권한 대상 전화번호 추가 및 권한 토글 활성화
This commit is contained in:
@@ -42,6 +42,10 @@ export function renderNavigation(onTabChange: (tab: string) => void) {
|
||||
};
|
||||
|
||||
const render = () => {
|
||||
// 특정 전화번호 관리자 화이트리스트
|
||||
const allowedAdminMobiles = ['01086270921', '01045278434', '01042470144', '01041585840'];
|
||||
const showRoleToggle = allowedAdminMobiles.includes(state.currentUserMobile || '');
|
||||
|
||||
// 1. 헤더 구조 (Vercel Style: Clean Single Row)
|
||||
headerContainer.innerHTML = `
|
||||
<div class="brand" id="btn-home-logo" style="cursor: pointer;">
|
||||
@@ -52,6 +56,7 @@ export function renderNavigation(onTabChange: (tab: string) => void) {
|
||||
<nav class="integrated-nav" id="main-nav-list"></nav>
|
||||
|
||||
<div class="header-actions">
|
||||
${showRoleToggle ? `
|
||||
<div class="role-toggle-wrapper">
|
||||
<span class="role-label user ${state.currentUserRole === 'user' ? 'active' : ''}">실무자</span>
|
||||
<label class="role-toggle">
|
||||
@@ -60,6 +65,7 @@ export function renderNavigation(onTabChange: (tab: string) => void) {
|
||||
</label>
|
||||
<span class="role-label admin ${state.currentUserRole === 'admin' ? 'active' : ''}">관리자</span>
|
||||
</div>
|
||||
` : ''}
|
||||
<div class="notification-area">
|
||||
<button class="icon-btn" title="알림"><i data-lucide="bell" style="width:18px; height:18px;"></i></button>
|
||||
</div>
|
||||
|
||||
26
src/main.ts
26
src/main.ts
@@ -23,7 +23,9 @@ import { createIcons, Plus, X, LayoutDashboard, Monitor, Server, Database, Lapto
|
||||
|
||||
interface AuthSessionResponse {
|
||||
authenticated: boolean;
|
||||
user: unknown;
|
||||
user: {
|
||||
loginId: string;
|
||||
} | null;
|
||||
}
|
||||
|
||||
let phoneLoginPollTimer: number | undefined;
|
||||
@@ -247,14 +249,24 @@ function initRoleSwitcher() {
|
||||
/**
|
||||
* 앱 초기화 (로그인 과정 없이 즉시 시작)
|
||||
*/
|
||||
function initializeAppDirectly() {
|
||||
function initializeAppDirectly(userMobile: string) {
|
||||
const loginContainer = document.getElementById('login-container');
|
||||
const appLayout = document.getElementById('app-layout');
|
||||
|
||||
// 기본 권한 설정: 실무자 (User)
|
||||
state.currentUserRole = 'user';
|
||||
state.currentUserMobile = userMobile;
|
||||
|
||||
// 허용할 관리자 특정 전화번호 목록
|
||||
const allowedAdminMobiles = ['01086270921', '01045278434', '01042470144', '01041585840'];
|
||||
|
||||
if (allowedAdminMobiles.includes(userMobile)) {
|
||||
state.currentUserRole = 'admin';
|
||||
state.activeSubTab = '대시보드';
|
||||
} else {
|
||||
state.currentUserRole = 'user';
|
||||
state.activeSubTab = '서버'; // 실무자 기본 탭
|
||||
}
|
||||
|
||||
state.activeCategory = 'hw';
|
||||
state.activeSubTab = '서버'; // 실무자 기본 탭
|
||||
|
||||
// 화면 전환
|
||||
if (loginContainer) loginContainer.style.display = 'none';
|
||||
@@ -321,7 +333,7 @@ function showLoginScreen(errorMessage?: string) {
|
||||
|
||||
if (payload.status === 'authenticated') {
|
||||
clearPhonePollTimer();
|
||||
initializeAppDirectly();
|
||||
initializeAppDirectly(payload.user?.loginId || '');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -401,7 +413,7 @@ async function bootstrapApp() {
|
||||
const response = await fetch('/api/auth/session');
|
||||
const sessionInfo = await response.json() as AuthSessionResponse;
|
||||
if (response.ok && sessionInfo.authenticated) {
|
||||
initializeAppDirectly();
|
||||
initializeAppDirectly(sessionInfo.user?.loginId || '');
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user