Skip to content

Commit 0cc27fb

Browse files
authored
Merge pull request NdoleStudio#930 from NdoleStudio/feat/settings-verify-email-button
feat(web): add verify email button on settings page
2 parents 4eb8851 + 4d2a4bf commit 0cc27fb

1 file changed

Lines changed: 41 additions & 2 deletions

File tree

web/app/pages/settings/index.vue

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ import {
1515
mdiCalendarClock,
1616
mdiPlus,
1717
} from '@mdi/js'
18-
import { getAuth, signOut, type User as FirebaseUser } from 'firebase/auth'
18+
import {
19+
getAuth,
20+
sendEmailVerification,
21+
signOut,
22+
type User as FirebaseUser,
23+
} from 'firebase/auth'
1924
import QRCode from 'qrcode'
2025
import { ErrorMessages } from '~/utils/errors'
2126
import { toApiError } from '~/utils/api-error'
@@ -45,6 +50,29 @@ const notificationsStore = useNotificationsStore()
4550
4651
const firebaseUser = ref<FirebaseUser | null>(null)
4752
const gravatarUrl = ref<string | null>(null)
53+
const sendingVerificationEmail = ref(false)
54+
const verificationEmailSent = ref(false)
55+
56+
async function sendVerificationEmail() {
57+
if (!firebaseUser.value) return
58+
sendingVerificationEmail.value = true
59+
try {
60+
await sendEmailVerification(firebaseUser.value)
61+
verificationEmailSent.value = true
62+
notificationsStore.addNotification({
63+
message: 'Verification email sent. Please check your inbox.',
64+
type: 'success',
65+
})
66+
} catch (error) {
67+
console.error('sendEmailVerification failed:', error)
68+
notificationsStore.addNotification({
69+
message: 'Failed to send verification email. Please try again later.',
70+
type: 'error',
71+
})
72+
} finally {
73+
sendingVerificationEmail.value = false
74+
}
75+
}
4876
4977
const computeGravatarUrl = async (email: string): Promise<string> => {
5078
const normalized = email.trim().toLowerCase()
@@ -819,6 +847,17 @@ onMounted(async () => {
819847
color="primary"
820848
:icon="mdiShieldCheck"
821849
/>
850+
<VBtn
851+
v-else
852+
size="x-small"
853+
variant="tonal"
854+
color="warning"
855+
:loading="sendingVerificationEmail"
856+
:disabled="verificationEmailSent"
857+
@click="sendVerificationEmail"
858+
>
859+
Verify Email
860+
</VBtn>
822861
</h4>
823862
<VAutocomplete
824863
v-if="authStore.user"
@@ -834,7 +873,7 @@ onMounted(async () => {
834873
</div>
835874

836875
<!-- API Key -->
837-
<h5 class="text-headline-large mb-3 mt-3">API Key</h5>
876+
<h5 class="text-headline-large mb-3 mt-0">API Key</h5>
838877
<p class="text-medium-emphasis">
839878
Use your API Key in the <v-code>x-api-key</v-code> HTTP Header
840879
when sending requests to

0 commit comments

Comments
 (0)