From 24b531652d498a7cae449fbeb2e86ec6538cecd5 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Wed, 7 Jan 2026 21:10:03 -0500 Subject: [PATCH] Added warning message when logged out due to timeout. --- web-app/src/assets/main.css | 12 ++++++++++++ web-app/src/components/IdleTimeoutModal.vue | 4 ++-- web-app/src/pages/LoginPage.vue | 18 +++++++++++++++++- web-app/src/pages/UserAccountLayout.vue | 8 ++++---- web-app/src/stores/auth-store.ts | 16 +++++++++++++--- 5 files changed, 48 insertions(+), 10 deletions(-) diff --git a/web-app/src/assets/main.css b/web-app/src/assets/main.css index 8317281..13d9690 100644 --- a/web-app/src/assets/main.css +++ b/web-app/src/assets/main.css @@ -61,3 +61,15 @@ a:hover { border: 2px solid var(--theme-secondary); padding: 0.1rem 0.25rem; } + +/* An alert banner, usually using

, to present some highlighted info. */ +.alert-banner { + background-color: var(--bg-lighter); + padding: 0.5rem; + border-radius: 0.5rem; +} + +.alert-banner-warning { + background-color: var(--warning); + color: var(--bg); +} diff --git a/web-app/src/components/IdleTimeoutModal.vue b/web-app/src/components/IdleTimeoutModal.vue index 1874a8f..111c5d5 100644 --- a/web-app/src/components/IdleTimeoutModal.vue +++ b/web-app/src/components/IdleTimeoutModal.vue @@ -1,5 +1,5 @@ @@ -87,7 +87,7 @@ async function checkAuth() { diff --git a/web-app/src/stores/auth-store.ts b/web-app/src/stores/auth-store.ts index 541963c..5394f46 100644 --- a/web-app/src/stores/auth-store.ts +++ b/web-app/src/stores/auth-store.ts @@ -9,20 +9,31 @@ export interface AuthenticatedData { const LOCAL_STORAGE_KEY = 'token' +export enum LogoutReason { + USER_LOGGED_OUT, + INACTIVITY_TIMEOUT, + TOKEN_EXPIRED, +} + export const useAuthStore = defineStore('auth', () => { + console.log('Initializing authStore') + const state: Ref = ref(getStateFromLocalStorage()) + const logoutReason: Ref = ref(null) function onUserLoggedIn(username: string, token: string) { state.value = { username, token } + logoutReason.value = null localStorage.setItem(LOCAL_STORAGE_KEY, token) } - function onUserLoggedOut() { + function onUserLoggedOut(reason: LogoutReason) { state.value = null + logoutReason.value = reason localStorage.removeItem(LOCAL_STORAGE_KEY) } - return { state, onUserLoggedIn, onUserLoggedOut } + return { state, logoutReason, onUserLoggedIn, onUserLoggedOut } }) function getStateFromLocalStorage(): AuthenticatedData | null { @@ -32,6 +43,5 @@ function getStateFromLocalStorage(): AuthenticatedData | null { return null } const username = parseSubject(token) - console.info('Loaded authentication information for user', username) return { username, token } }