javascript - reauthenticateWithCredential 错误获取错误 TypeError: credential._getReauthenticationResolver is not a function (firebase 9)
问题描述
我正在学习火力基地。现在想用 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)
});
谁能指出错误在哪里?
解决方案
也许仍然不太正确,但试一试:
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);
}
推荐阅读
- c# - 请求标头未转发到 IdentityServer4
- reactjs - 使用 TypeScript 时获取类型属性不存在错误
- java - Spring 中的作用域代理是什么?
- python - 动态和变化的 XPATH
- cakephp - 用于自引用 belongsToMany 关联的插入/删除方法
- java - 类 'org.apache.http.message.BufferedHeader' 没有实现接口 'org.apache.http.NameValuePair'
- javascript - 我如何在 Firebase 中创建一个自定义数据库并使用 React Native
- sql - 对两个单独的 SQL 表中的列求和
- python - Python在While循环中继续缩进
- windows - Master 卡在“等待端口 4445 上可能的 Shutdown/StopTestNow/HeapDump/ThreadDump 消息”