Ajoute les pages de compte au front et le favicon de la SSMG
- Inscription, suivi de l'inscription (lien de confirmation), seconde étape de connexion (code à 6 chiffres ou code de secours), mot de passe oublié et réinitialisation, page « Mon compte » (mot de passe, 2FA avec QR code et codes de secours), d'après les maquettes Penpot. - Les jetons reçus par e-mail sont retirés de l'URL dès l'arrivée. - Favicon de la SSMG (ssmg.be) ; retour en haut de page à chaque navigation. - 93 tests Vitest ; README et CLAUDE.md mis à jour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d2da878dbd
commit
0617fa8dc4
29 files changed
+2305
-58
No files matched your search
@@ -0,0 +1,119 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
import { api, ApiError } from '@/api/client'
|
||||
|
||||
type State = 'loading' | 'sent' | 'confirmed' | 'expired' | 'invalid' | 'used'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const state = ref<State>('loading')
|
||||
const email = ref<string>((history.state?.email as string | undefined) ?? '')
|
||||
const token = ref('')
|
||||
const resent = ref(false)
|
||||
const resending = ref(false)
|
||||
|
||||
onMounted(async () => {
|
||||
const jeton = route.query.jeton
|
||||
if (typeof jeton !== 'string' || !jeton) {
|
||||
state.value = 'sent'
|
||||
return
|
||||
}
|
||||
token.value = jeton
|
||||
// Retire le jeton de la barre d'adresse et de l'historique.
|
||||
await router.replace({ name: 'register-status' })
|
||||
try {
|
||||
await api.verifyEmail(jeton)
|
||||
state.value = 'confirmed'
|
||||
} catch (e) {
|
||||
const code = e instanceof ApiError ? e.code : undefined
|
||||
state.value = code === 'expired_token' ? 'expired' : code === 'used_token' ? 'used' : 'invalid'
|
||||
}
|
||||
})
|
||||
|
||||
async function resend() {
|
||||
resending.value = true
|
||||
try {
|
||||
await api.resendVerification(token.value ? { token: token.value } : { email: email.value })
|
||||
resent.value = true
|
||||
} finally {
|
||||
resending.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const ICONS: Record<State, string> = {
|
||||
loading: 'bi-hourglass-split',
|
||||
sent: 'bi-envelope',
|
||||
confirmed: 'bi-check-lg',
|
||||
expired: 'bi-clock-history',
|
||||
invalid: 'bi-x-lg',
|
||||
used: 'bi-check-lg',
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="auth-page">
|
||||
<section
|
||||
class="auth-card wide prism-card text-center"
|
||||
aria-labelledby="status-title"
|
||||
aria-live="polite"
|
||||
>
|
||||
<div class="icon-circle" aria-hidden="true"><i class="bi" :class="ICONS[state]"></i></div>
|
||||
|
||||
<template v-if="state === 'loading'">
|
||||
<h1 id="status-title">{{ $t('registerStatus.loading') }}</h1>
|
||||
</template>
|
||||
|
||||
<template v-else-if="state === 'sent'">
|
||||
<h1 id="status-title">{{ $t('registerStatus.sent.title') }}</h1>
|
||||
<p v-if="email">{{ $t('registerStatus.sent.textTo', { email }) }}</p>
|
||||
<p v-else>{{ $t('registerStatus.sent.text') }}</p>
|
||||
<p class="form-text">{{ $t('registerStatus.sent.hint') }}</p>
|
||||
<button
|
||||
v-if="email"
|
||||
type="button"
|
||||
class="btn btn-outline-primary"
|
||||
:disabled="resending || resent"
|
||||
@click="resend"
|
||||
>
|
||||
{{ $t('registerStatus.resend') }}
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<template v-else-if="state === 'confirmed' || state === 'used'">
|
||||
<h1 id="status-title">{{ $t('registerStatus.confirmed.title') }}</h1>
|
||||
<p>{{ $t('registerStatus.confirmed.text') }}</p>
|
||||
<RouterLink :to="{ name: 'login' }" class="btn btn-primary">
|
||||
{{ $t('registerStatus.toLogin') }}
|
||||
</RouterLink>
|
||||
</template>
|
||||
|
||||
<template v-else-if="state === 'expired'">
|
||||
<h1 id="status-title">{{ $t('registerStatus.expired.title') }}</h1>
|
||||
<p>{{ $t('registerStatus.expired.text') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
:disabled="resending || resent"
|
||||
@click="resend"
|
||||
>
|
||||
{{ $t('registerStatus.resend') }}
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<h1 id="status-title">{{ $t('registerStatus.invalid.title') }}</h1>
|
||||
<p>{{ $t('registerStatus.invalid.text') }}</p>
|
||||
<RouterLink :to="{ name: 'register' }" class="btn btn-outline-primary">
|
||||
{{ $t('registerStatus.restart') }}
|
||||
</RouterLink>
|
||||
</template>
|
||||
|
||||
<p v-if="resent" class="text-success mt-3 mb-0" role="status">
|
||||
{{ $t('registerStatus.resent') }}
|
||||
</p>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user