로그인 정보 저장 제거
This commit is contained in:
@@ -20,13 +20,14 @@ const state = {
|
||||
eventSource: null,
|
||||
launchTimer: 0,
|
||||
activeView: "locations",
|
||||
adminToken: new URLSearchParams(window.location.search).get("adminToken") ||
|
||||
window.localStorage.getItem("cargoRadarAdminToken") ||
|
||||
""
|
||||
adminToken: new URLSearchParams(window.location.search).get("adminToken") || ""
|
||||
};
|
||||
|
||||
const LOGIN_SESSION_KEY = "cargoRadarLoginReady";
|
||||
const LOGIN_NAME_KEY = "cargoRadarLoginName";
|
||||
const LEGACY_LOGIN_STORAGE_KEYS = [
|
||||
"cargoRadarLoginReady",
|
||||
"cargoRadarLoginName",
|
||||
"cargoRadarAdminToken"
|
||||
];
|
||||
const LAUNCH_STEPS = [
|
||||
{
|
||||
title: "관제 데이터 연결 중",
|
||||
@@ -145,13 +146,10 @@ const VEHICLE_TYPES = {
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const sessionReady = initializeLoginState();
|
||||
initializeLoginState();
|
||||
startSystemClock();
|
||||
initializeMap();
|
||||
bindActions();
|
||||
if (sessionReady) {
|
||||
startDataServices();
|
||||
}
|
||||
});
|
||||
|
||||
function startDataServices() {
|
||||
@@ -320,29 +318,17 @@ function bindActions() {
|
||||
}
|
||||
|
||||
function initializeLoginState() {
|
||||
const sessionReady = window.localStorage.getItem(LOGIN_SESSION_KEY) === "true";
|
||||
const savedName = window.localStorage.getItem(LOGIN_NAME_KEY) || "";
|
||||
elements.loginNameInput.value = savedName;
|
||||
|
||||
if (sessionReady) {
|
||||
hideLoginScreen({ instant: true });
|
||||
return true;
|
||||
}
|
||||
|
||||
clearStoredLoginState();
|
||||
elements.loginNameInput.value = "";
|
||||
showLoginScreen({ instant: true });
|
||||
return false;
|
||||
}
|
||||
|
||||
function submitLoginForm(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const name = elements.loginNameInput.value.trim();
|
||||
const code = elements.loginCodeInput.value.trim();
|
||||
state.adminToken = code || state.adminToken || "demo";
|
||||
|
||||
window.localStorage.setItem(LOGIN_SESSION_KEY, "true");
|
||||
window.localStorage.setItem(LOGIN_NAME_KEY, name || "관제 담당자");
|
||||
window.localStorage.setItem("cargoRadarAdminToken", state.adminToken);
|
||||
elements.loginCodeInput.value = "";
|
||||
beginLaunchSequence();
|
||||
startDataServices();
|
||||
@@ -350,7 +336,7 @@ function submitLoginForm(event) {
|
||||
|
||||
function showLoginScreen(options = {}) {
|
||||
clearLaunchSequence();
|
||||
window.localStorage.removeItem(LOGIN_SESSION_KEY);
|
||||
clearStoredLoginState();
|
||||
if (state.eventSource) {
|
||||
state.eventSource.close();
|
||||
state.eventSource = null;
|
||||
@@ -363,6 +349,12 @@ function showLoginScreen(options = {}) {
|
||||
window.setTimeout(() => elements.loginNameInput.focus(), options.instant ? 80 : 220);
|
||||
}
|
||||
|
||||
function clearStoredLoginState() {
|
||||
for (const key of LEGACY_LOGIN_STORAGE_KEYS) {
|
||||
window.localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
|
||||
function hideLoginScreen(options = {}) {
|
||||
if (options.instant) {
|
||||
document.body.classList.remove("is-login-active", "is-login-closing");
|
||||
@@ -1981,7 +1973,6 @@ function requestAdminToken() {
|
||||
}
|
||||
|
||||
state.adminToken = token.trim();
|
||||
window.localStorage.setItem("cargoRadarAdminToken", state.adminToken);
|
||||
refreshDrivers();
|
||||
refreshLatestLocations();
|
||||
connectEvents();
|
||||
|
||||
Reference in New Issue
Block a user