email verification

This commit is contained in:
Rafi
2023-03-03 18:50:02 +08:00
parent ef6657187a
commit f166581a73
10 changed files with 185 additions and 203 deletions

View File

@@ -3,18 +3,29 @@ definePageMeta({
layout: 'vuetify-app',
middleware: ['auth']
})
const email = ref('')
const route = useRoute()
const sending = ref(false)
const resent = ref(false)
const errorMsg = ref(null)
const resendEmail = async () => {
errorMsg.value = null
sending.value = true
const { data, error } = await useFetch('/api/account/resend-verification-email/', {
method: 'POST'
const { data, error } = await useFetch('/api/account/registration/resend-email/', {
method: 'POST',
})
if (error.value) {
console.log(error.value)
errorMsg.value = 'Something went wrong. Please try again later.'
} else {
resent.value = true
}
sending.value = false
}
onNuxtReady(() => {
if (route.query.resend) {
resendEmail()
}
})
</script>
<template>
@@ -36,17 +47,21 @@ const resendEmail = async () => {
<div class="text-center">
<h2 class="text-h4">Verify your email</h2>
<p class="text-body-2 mt-5">
We've sent a verification email to <strong>{{ email }}</strong>. <br>
We've sent a verification email to <strong>{{ $auth.user.email }}</strong>. <br>
Please check your inbox and click the link to verify your email address.
</p>
<p v-if="errorMsg"
class="text-red"
>{{ errorMsg }}</p>
<v-btn
variant="text"
class="mt-5"
color="primary"
:loading="sending"
@click="resendEmail"
:disabled="resent"
>
Resend email
{{ resent ? 'Resent' : 'Resend email'}}
</v-btn>
</div>
</v-card>