Firebase 身份验证:在不使用“sendPasswordResetEmail”的情况下更新(未登录用户)密码

时间:2021-06-24 10:59:08

标签: javascript firebase firebase-authentication

我知道如何在 firebase auth 中更新登录用户的密码:

var user = firebase.auth().currentUser; //get current connected user
    return user.updatePassword(newPass)
      .then(
        () => //success
      )
      .catch(error => this.handleError(error))
  }

但我不知道如何对未登录的用户做同样的事情。也许只能用他的电子邮件来检索用户身份验证持久性(但没有办法做到这一点):

var user = firebase.auth().getUserByEmail(email); //not implmented in auth firebase

PS:我不想使用方法 sendPasswordResetEmail()

var auth = firebase.auth();
    return auth.sendPasswordResetEmail(email);

非常感谢帮助, 谢谢!

1 个答案:

答案 0 :(得分:0)

客户端 Firebase SDK 允许向当前登录的用户发送密码重置(和其他消息),因为任何其他调用都是主要的滥用媒介。因此,无法仅根据用户的电子邮件地址向用户发送密码重置消息。

如果您想要此功能,则必须自己实现。在该过程结束时,您可以使用 Firebase Admin SDK update the password 在用户的个人资料中。

另见: