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