微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决使用 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 举报,一经查实,本站将立刻删除。