我正在學習Firebase。現在想用reauthenticateWithCredential()來改變密碼,但得到的錯誤是這樣的。
型別錯誤:credential._getReauthenticationResolver不是一個函式
。
這段代碼:
span class="hljs-keyword">import { getAuth, reauthenticateWithCredential, signInWithEmailAndPassword } from "firebase/auth"。
const auth = getAuth();
const user = auth.currentUser;
const credential = signInWithEmailAndPassword(auth, user. email, this.oldPassword)。)
reauthenticateWithCredential(user, credential).then(() => {
//用戶重新認證。
console.log(credential)
}).catch((error) =>/span> {
console.log(錯誤)。
});
有人能指出錯誤在哪里嗎?
uj5u.com熱心網友回復:
也許還是不太對,但可以試試這個 :
import {
getAuth,
reauthenticateWithCredential,
EmailAuthProvider。
} from "firebase/auth"。
const auth = getAuth();
const user = auth.currentUser;
try {
const credential = EmailAuthProvider.credential(
user.email。
this.oldPassword.
);
reauthenticateWithCredential(user, credential).then(( ) => {
//用戶重新認證.
//代碼...。
});
} catch (錯誤) {
console.log(error.message)。
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/308595.html
標籤:
