feat: add CIE authentication callback page with polling mechanism for session verification

This commit is contained in:
gabdevele
2026-06-17 18:03:40 +02:00 Unverified
parent b75e7bbafd
commit 4c42c7963c
5 changed files with 397 additions and 1029 deletions
+27 -3
View File
@@ -7,16 +7,20 @@ definePageMeta({
useHead({ title: 'Accedi - Visione' })
const { requestOtp, verifyOtp, handleLoginSuccess } = useAuth()
const runtimeConfig = useRuntimeConfig()
const { requestOtp, verifyOtp, handleLoginSuccess, startCieLogin } = useAuth()
// UI State
const otpStep = ref<1 | 2>(1)
const isLoading = ref(false)
const isCieLoading = ref(false)
const errorMessage = ref('')
const email = ref('')
const otpCode = ref('')
const cieCallbackUrl = `${runtimeConfig.public.url}/auth/cie/callback`
const handleRequestOtp = async () => {
isLoading.value = true
errorMessage.value = ''
@@ -42,6 +46,21 @@ const handleVerifyOtp = async () => {
isLoading.value = false
}
}
const handleCieLogin = async () => {
isCieLoading.value = true
errorMessage.value = ''
try {
const res = await startCieLogin(cieCallbackUrl)
await navigateTo(res.authorization_url, {
external: true,
replace: true,
})
} catch (err: any) {
errorMessage.value = err.data?.message || 'Avvio autenticazione CIE non riuscito. Riprova.'
isCieLoading.value = false
}
}
</script>
<template>
@@ -61,9 +80,14 @@ const handleVerifyOtp = async () => {
<div class="card-body p-4 p-md-5">
<button class="btn btn-primary w-100 mb-4 d-flex align-items-center justify-content-center gap-2" disabled title="Integrazione CIE prevista per la fase successiva">
<button
class="btn btn-primary w-100 mb-4 d-flex align-items-center justify-content-center gap-2"
:disabled="isCieLoading || isLoading"
@click="handleCieLogin"
>
<span v-if="isCieLoading" class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
<BIIcon name="it-card" size="sm" color="white" />
Entra con CIE (Presto disponibile)
Entra con CIE
</button>
<div class="d-flex align-items-center my-4">