[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

@@ -11,7 +11,8 @@ import {
setPersistence,
signInWithEmailAndPassword,
signInWithPopup,
signOut
signOut,
updatePassword
} from 'firebase/auth'
import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
@@ -224,6 +225,14 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
sendPasswordResetEmail(authInstance, email)
)
/** Update password for current user */
const _updatePassword = async (newPassword: string): Promise<void> => {
if (!currentUser.value) {
throw new FirebaseAuthStoreError(t('toastMessages.userNotAuthenticated'))
}
await updatePassword(currentUser.value, newPassword)
}
const addCredits = async (
requestBodyContent: CreditPurchasePayload
): Promise<CreditPurchaseResponse> => {
@@ -319,6 +328,7 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
initiateCreditPurchase,
fetchBalance,
accessBillingPortal,
sendPasswordReset
sendPasswordReset,
updatePassword: _updatePassword
}
})