[Auth] Allow change password in user panel (#3699)

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chenlei Hu
2025-04-30 16:12:57 -04:00
committed by GitHub
parent a43d1e1ee8
commit 834d5820d2
15 changed files with 305 additions and 169 deletions

View File

@@ -0,0 +1,47 @@
<template>
<Form
class="flex flex-col gap-6 w-96"
:resolver="zodResolver(updatePasswordSchema)"
@submit="onSubmit"
>
<PasswordFields />
<!-- Submit Button -->
<Button
type="submit"
:label="$t('userSettings.updatePassword')"
class="h-10 font-medium mt-4"
:loading="loading"
/>
</Form>
</template>
<script setup lang="ts">
import { Form, FormSubmitEvent } from '@primevue/forms'
import { zodResolver } from '@primevue/forms/resolvers/zod'
import Button from 'primevue/button'
import { ref } from 'vue'
import PasswordFields from '@/components/dialog/content/signin/PasswordFields.vue'
import { updatePasswordSchema } from '@/schemas/signInSchema'
import { useFirebaseAuthService } from '@/services/firebaseAuthService'
const authService = useFirebaseAuthService()
const loading = ref(false)
const { onSuccess } = defineProps<{
onSuccess: () => void
}>()
const onSubmit = async (event: FormSubmitEvent) => {
if (event.valid) {
loading.value = true
try {
await authService.updatePassword(event.values.password)
onSuccess()
} finally {
loading.value = false
}
}
}
</script>