[API Node] Reset password (#3578)

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Christian Byrne
2025-04-23 22:13:17 +08:00
committed by GitHub
parent 16bd9abccd
commit 59cbe90fd3
9 changed files with 53 additions and 2 deletions

View File

@@ -36,7 +36,10 @@
>
{{ t('auth.login.passwordLabel') }}
</label>
<span class="text-muted text-base font-medium cursor-pointer">
<span
class="text-muted text-base font-medium cursor-pointer"
@click="handleForgotPassword($form.email?.value)"
>
{{ t('auth.login.forgotPassword') }}
</span>
</div>
@@ -79,11 +82,13 @@ import { useI18n } from 'vue-i18n'
import { type SignInData, signInSchema } from '@/schemas/signInSchema'
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
import { useToastStore } from '@/stores/toastStore'
const authStore = useFirebaseAuthStore()
const loading = computed(() => authStore.loading)
const { t } = useI18n()
const toast = useToastStore()
const emit = defineEmits<{
submit: [values: SignInData]
@@ -94,4 +99,22 @@ const onSubmit = (event: FormSubmitEvent) => {
emit('submit', event.values as SignInData)
}
}
const handleForgotPassword = async (email: string) => {
if (!email) return
await authStore.sendPasswordReset(email)
if (authStore.error) {
toast.add({
severity: 'error',
summary: t('auth.login.forgotPasswordError'),
detail: authStore.error
})
} else {
toast.add({
severity: 'success',
summary: t('auth.login.passwordResetSent'),
detail: t('auth.login.passwordResetSentDetail')
})
}
}
</script>