我在学习火药库。现在想用reauthenticateWithCredential()更改密码。但要犯这样的错误。
TypeError: credential._getReauthenticationResolver不是一个函数
这是密码:
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(() => {
// User re-authenticated.
console.log(credential)
}).catch((error) => {
console.log(error)
});有人能指出错误在哪里吗?
发布于 2021-09-15 02:30:02
也许还是不太对,但试试看:
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(() => {
// User re-authenticated.
// Code...
});
} catch (error) {
console.log(error.message);
}https://stackoverflow.com/questions/69186075
复制相似问题