首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >reauthenticateWithCredential get error TypeError: credential._getReauthenticationResolver不是函数(firebase 9)

reauthenticateWithCredential get error TypeError: credential._getReauthenticationResolver不是函数(firebase 9)
EN

Stack Overflow用户
提问于 2021-09-15 01:19:57
回答 1查看 810关注 0票数 9

我在学习火药库。现在想用reauthenticateWithCredential()更改密码。但要犯这样的错误。

TypeError: credential._getReauthenticationResolver不是一个函数

这是密码:

代码语言:javascript
复制
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)
});

有人能指出错误在哪里吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-15 02:30:02

也许还是不太对,但试试看:

代码语言:javascript
复制
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);
}
票数 11
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69186075

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档