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 : ''
|
||||
})
|
||||
|
||||
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 errorMessage = ref('')
|
||||
const statusMessage = ref('Verifica dell’autenticazione CIE in corso...')
|
||||
@@ -50,6 +65,18 @@ const redirectToLoginError = async (code: string, fallbackMessage: string) => {
|
||||
}
|
||||
|
||||
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) {
|
||||
await redirectToLoginError('invalid_session', 'Sessione CIE non valida: parametro state mancante.')
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user