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 } }