gpt4 book ai didi

javascript - reauthenticateWithCredential 错误获取错误 TypeError : credential. _getReauthenticationResolver 不是函数(firebase 9)

转载 作者:行者123 更新时间:2023-12-05 00:26:38 26 4
gpt4 key购买 nike

我正在学习火力基地。现在想用 reauthenticateWithCredential() 更改密码。但得到这样的错误。

TypeError: credential._getReauthenticationResolver is not a function


这是代码:
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)
});
谁能指出错误在哪里?

最佳答案

也许仍然不太正确,但试一试:

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);
}

关于javascript - reauthenticateWithCredential 错误获取错误 TypeError : credential. _getReauthenticationResolver 不是函数(firebase 9),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69186075/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com