feat: add error handling for CIE authentication and improve user feedback on login page
This commit is contained in:
@@ -16,6 +16,21 @@ const state = computed(() => {
|
|||||||
return typeof value === 'string' ? value : ''
|
return typeof value === 'string' ? value : ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const providerError = computed(() => {
|
||||||
|
const value = route.query.error
|
||||||
|
return typeof value === 'string' ? value : ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const providerCieError = computed(() => {
|
||||||
|
const value = route.query.cie_error
|
||||||
|
return typeof value === 'string' ? value : ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const providerErrorDescription = computed(() => {
|
||||||
|
const value = route.query.error_description
|
||||||
|
return typeof value === 'string' ? value : ''
|
||||||
|
})
|
||||||
|
|
||||||
const isLoading = ref(true)
|
const isLoading = ref(true)
|
||||||
const errorMessage = ref('')
|
const errorMessage = ref('')
|
||||||
const statusMessage = ref('Verifica dell’autenticazione CIE in corso...')
|
const statusMessage = ref('Verifica dell’autenticazione CIE in corso...')
|
||||||
@@ -50,6 +65,18 @@ const redirectToLoginError = async (code: string, fallbackMessage: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const checkSession = async () => {
|
const checkSession = async () => {
|
||||||
|
if (providerError.value || providerCieError.value) {
|
||||||
|
const isCancelled = providerErrorDescription.value.toLowerCase().includes('rejected by user')
|
||||||
|
|| providerError.value === 'access_denied'
|
||||||
|
|| providerCieError.value === 'invalid_request'
|
||||||
|
|
||||||
|
await redirectToLoginError(
|
||||||
|
isCancelled ? 'cancelled' : 'failed',
|
||||||
|
providerErrorDescription.value || 'Autenticazione CIE non completata. Riprova dal login.'
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!state.value) {
|
if (!state.value) {
|
||||||
await redirectToLoginError('invalid_session', 'Sessione CIE non valida: parametro state mancante.')
|
await redirectToLoginError('invalid_session', 'Sessione CIE non valida: parametro state mancante.')
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ const cieErrorMessage = computed(() => {
|
|||||||
|
|
||||||
const messages: Record<string, string> = {
|
const messages: Record<string, string> = {
|
||||||
invalid_session: 'Sessione CIE non valida o incompleta. Avvia di nuovo accesso con CIE.',
|
invalid_session: 'Sessione CIE non valida o incompleta. Avvia di nuovo accesso con CIE.',
|
||||||
|
cancelled: 'Accesso con CIE annullato. Se vuoi, riprova dal pulsante Entra con CIE.',
|
||||||
failed: 'Autenticazione CIE non completata. Riprova dal pulsante Entra con CIE.',
|
failed: 'Autenticazione CIE non completata. Riprova dal pulsante Entra con CIE.',
|
||||||
timeout: 'Tempo di attesa scaduto durante verifica CIE. Riprova.',
|
timeout: 'Tempo di attesa scaduto durante verifica CIE. Riprova.',
|
||||||
verification_error: 'Errore durante verifica autenticazione CIE. Riprova tra poco.'
|
verification_error: 'Errore durante verifica autenticazione CIE. Riprova tra poco.'
|
||||||
|
|||||||
Reference in New Issue
Block a user