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