Initial commit
This commit is contained in:
43
pages/auth/verify-email/[token].vue
Normal file
43
pages/auth/verify-email/[token].vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<div class="text-center mt-10">
|
||||
<h1 class="text-2xl font-bold">E-Mail wird verifiziert...</h1>
|
||||
<p>Bitte einen Moment Geduld.</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const localePath = useLocalePath()
|
||||
const config = useRuntimeConfig()
|
||||
const apiBase = config.public.apiUrl
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const token = route.params.token
|
||||
await axios.get(`${apiBase}/api/verify-email/${token}`)
|
||||
|
||||
// Weiterleitung mit Query-Param (z.B. für Erfolgsmeldung im Login)
|
||||
router.push({
|
||||
path: localePath('/auth/login'),
|
||||
query: { verified: '1' }
|
||||
})
|
||||
} catch (error) {
|
||||
if (error.response && (error.response.status === 400 || error.response.status === 404)) {
|
||||
// Token ungültig oder abgelaufen – Weiterleitung zur Registrierung
|
||||
router.push({
|
||||
path: localePath('/auth/signup'),
|
||||
query: { error: 'invalid_or_expired_token' }
|
||||
})
|
||||
} else {
|
||||
router.push({
|
||||
path: localePath('/auth/login'),
|
||||
query: { error: 'verification_failed' }
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
Reference in New Issue
Block a user