opnform/client/pages/auth/verification/verify.vue

60 lines
1.3 KiB
Vue
Raw Normal View History

2023-12-09 14:47:03 +00:00
<template>
<div class="row">
<div class="col-lg-8 m-auto px-4">
<h1 class="my-6">
Verify Email
</h1>
<template v-if="success">
<div class="alert alert-success" role="alert">
{{ success }}
</div>
<NuxtLink :to="{ name: 'login' }" class="btn btn-primary">
2023-12-09 14:47:03 +00:00
Login
</NuxtLink>
2023-12-09 14:47:03 +00:00
</template>
<template v-else>
<div class="alert alert-danger" role="alert">
{{ error || 'Failed to verify email.' }}
</div>
<NuxtLink :to="{ name: 'auth-verification-resend' }" class="small float-right">
2023-12-09 14:47:03 +00:00
Resend Verification Link?
</NuxtLink>
2023-12-09 14:47:03 +00:00
</template>
</div>
</div>
</template>
<script>
import axios from 'axios'
import SeoMeta from '../../../mixins/seo-meta.js'
const qs = (params) => Object.keys(params).map(key => `${key}=${params[key]}`).join('&')
export default {
mixins: [SeoMeta],
async beforeRouteEnter (to, from, next) {
try {
const { data } = await axios.post(`/api/email/verify/${to.params.id}?${qs(to.query)}`)
next(vm => {
vm.success = data.status
})
} catch (e) {
next(vm => {
vm.error = e.response.data.status
})
}
},
middleware: 'guest',
data: () => ({
metaTitle: 'Verify Email',
error: '',
success: ''
})
}
</script>