feat: add error handling for CIE authentication and display messages on login page
This commit is contained in:
@@ -8,6 +8,7 @@ definePageMeta({
|
||||
useHead({ title: 'Accedi - Visione' })
|
||||
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const route = useRoute()
|
||||
const { requestOtp, verifyOtp, handleLoginSuccess, startCieLogin } = useAuth()
|
||||
|
||||
const otpStep = ref<1 | 2>(1)
|
||||
@@ -20,6 +21,21 @@ const otpCode = ref('')
|
||||
|
||||
const cieCallbackUrl = `${runtimeConfig.public.url}/auth/cie/callback`
|
||||
|
||||
const cieErrorMessage = computed(() => {
|
||||
const error = route.query.cie_error
|
||||
|
||||
if (typeof error !== 'string') return ''
|
||||
|
||||
const messages: Record<string, string> = {
|
||||
invalid_session: 'Sessione CIE non valida o incompleta. Avvia di nuovo accesso con CIE.',
|
||||
failed: 'Autenticazione CIE non completata. Riprova dal pulsante Entra con CIE.',
|
||||
timeout: 'Tempo di attesa scaduto durante verifica CIE. Riprova.',
|
||||
verification_error: 'Errore durante verifica autenticazione CIE. Riprova tra poco.'
|
||||
}
|
||||
|
||||
return messages[error] || 'Accesso con CIE non riuscito. Riprova.'
|
||||
})
|
||||
|
||||
const handleRequestOtp = async () => {
|
||||
isLoading.value = true
|
||||
errorMessage.value = ''
|
||||
@@ -94,6 +110,10 @@ const handleCieLogin = async () => {
|
||||
<hr class="flex-grow-1">
|
||||
</div>
|
||||
|
||||
<div v-if="cieErrorMessage" class="alert alert-danger mb-4" role="alert">
|
||||
{{ cieErrorMessage }}
|
||||
</div>
|
||||
|
||||
<div v-if="errorMessage" class="alert alert-danger mb-4" role="alert">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user