diff --git a/index.html b/index.html index a1f4b33..7439a27 100644 --- a/index.html +++ b/index.html @@ -66,6 +66,9 @@ + diff --git a/src/main.ts b/src/main.ts index 1822703..648c059 100644 --- a/src/main.ts +++ b/src/main.ts @@ -118,6 +118,19 @@ async function refreshAllData() { refreshView(); } +async function logoutAndReturnToLogin() { + try { + await fetch('/api/auth/logout', { + method: 'POST', + headers: { 'Content-Type': 'application/json' } + }); + } catch (error) { + console.error('Logout failed:', error); + } + + window.location.href = '/'; +} + // --- App Initialization --- function initApp() { const mainContent = document.getElementById('main-content')!; @@ -200,6 +213,11 @@ function initApp() { pcFlowModal.open(); return; } + + if (target.closest('#btn-logout-header')) { + logoutAndReturnToLogin(); + return; + } }); createIcons({