Better error messages from backend, avoid bad toasts, cleanup of session validation.

This commit is contained in:
Leo Vasanko
2025-12-02 16:37:27 +00:00
parent 77d8e97dc9
commit a05d4aec81
8 changed files with 33 additions and 44 deletions
+3 -3
View File
@@ -574,10 +574,10 @@ async function submitDialog() {
<StatusMessage />
<main class="app-main">
<LoadingView v-if="loading" :message="loadingMessage" />
<AuthRequiredMessage
v-else-if="showBackMessage"
<AuthRequiredMessage
v-else-if="showBackMessage"
message="You need to authenticate to access the admin panel."
@reload="reloadPage"
@reload="reloadPage"
/>
<section v-else class="view-root view-root--wide view-admin">
<header class="view-header">
+1 -1
View File
@@ -135,7 +135,7 @@ async function authenticateUser() {
loading.value = false
const message = error?.message || 'Passkey authentication cancelled'
const cancelled = message === 'Passkey authentication cancelled'
showMessage(cancelled ? message : `Authentication failed: ${message}`, cancelled ? 'info' : 'error', 4000)
showMessage(message, cancelled ? 'info' : 'error', 4000)
emit('auth-error', { message, cancelled })
return
}
@@ -4,7 +4,6 @@
@authenticated="handleAuthenticated"
@forbidden="handleForbidden"
@logout="handleLogout"
@auth-error="handleAuthError"
@back="handleBack"
/>
</template>
@@ -51,15 +50,6 @@ function handleLogout() {
})
}
function handleAuthError({ message, cancelled }) {
// Notify parent that authentication failed or was cancelled
postToParent({
type: 'auth-error',
message: message || 'Authentication failed',
cancelled
})
}
function handleBack() {
console.log('[RestrictedApiApp] Back clicked')
// Notify parent that user wants to go back
+1 -1
View File
@@ -112,7 +112,7 @@ export const useAuthStore = defineStore('auth', {
throw new Error('Authentication required')
}
const result = await response.json()
if (result.detail) throw new Error(`Server: ${result.detail}`)
if (result.detail) throw new Error(result.detail)
await this.loadUserInfo()
},
+1 -1
View File
@@ -59,7 +59,7 @@ class AwaitableWebSocket extends WebSocket {
throw new Error("Failed to parse JSON from WebSocket message")
}
if (parsed.detail) {
throw new Error(`Server: ${parsed.detail}`)
throw new Error(parsed.detail)
}
return parsed
}