fix: logout clears cookies + shows login form, module-list clear on re-login

This commit is contained in:
Accusys
2026-05-18 12:20:49 +08:00
parent b151494db8
commit 880425b335

View File

@@ -168,6 +168,7 @@ async function initApp() {
await initWasm(); await initWasm();
el.innerHTML = '<p>Building modules...</p>'; el.innerHTML = '<p>Building modules...</p>';
var listEl = document.getElementById('module-list'); var listEl = document.getElementById('module-list');
listEl.innerHTML = '';
MODULES.forEach(function(m) { MODULES.forEach(function(m) {
var a = document.createElement('a'); var a = document.createElement('a');
a.className = 'module-link'; a.className = 'module-link';
@@ -193,10 +194,14 @@ async function initApp() {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
try { try {
await fetch('/api/v1/auth/logout', {method:'POST'}); await fetch('/api/v1/auth/logout', {method:'POST', credentials:'include'});
} catch(_) {} } catch(_) {}
el.innerHTML = '<p style="color:#060">Logged out. Session cleared.</p>'; // Clear client-side cookies
document.getElementById('logout-btn').style.display = 'none'; document.cookie.split(';').forEach(function(c) {
document.cookie = c.trim().split('=')[0] + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
});
document.getElementById('sidebar').style.display = 'none';
showLoginForm();
}; };
// Load initial module from hash or default // Load initial module from hash or default