使用 updatePassword 启用密码更改并重新进行身份验证 (Firebase+Angular)

问题描述

我想允许在我正在构建的网站上更改密码。我使用了来自 stackoverflow 的信息和我在 Internet 上看到的信息,在使用 updatePassword 函数之前,建议使用 reauthenticate 来验证用户的身份。 以下功能对我不起作用,你知道为什么吗?

  auth_state: any = null;

  constructor(private firebaseAuth: AngularFireAuth) {
    this.firebaseAuth.auth_state.subscribe((auth =>{
      this.auth_state= auth;
    }))
  } 
  changePassword(new_password) {
    var credentials =  this.auth_state.prototype.reauthenticateWithCredential.EmailAuthProvider.credential("email@example.com","oldPassword");
    this.auth_state.prototype.reauthenticate(credentials)
      .then(() => {
        this.auth_state.prototype.updatePassword(new_password)
          .then(() => {
          })
          .catch((error) => {
            console.log(error);
          })
      })
      .catch((error) => {
        console.log(error);
      })
  }

我得到的错误是:

ERROR TypeError: Cannot read property 'reauthenticateWithCredential' of undefined

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)