node.js - 我可以使用 Firebase Admin SDK for Node 重置用户密码吗?

标签 node.js firebase firebase-admin

Firebase 的文档表明该 API 提供与控制台相同的功能:

It is not always convenient to have to visit the Firebase console in order to manage your Firebase users. The admin user management API provides programmatic access to those same users. It even allows you to do things the Firebase console cannot, such as retrieving a user's full data and changing a user's password, email address or phone number.

但是引用文档没有列出重置用户密码的功能。我错过了什么吗?

最佳答案

编辑:这个答案现在已经过时了,请参阅下面 Andrea 的答案,了解如何通过 Firebase SDK 发送密码重置链接。

这取决于您使用的“重置”定义。

如果您的意思是“更改”中的重置,那么是的 - the updateUser function 允许您提供新密码。请参阅文档中的以下示例:

admin.auth().updateUser(uid, {
  email: "modifiedUser@example.com",
  phoneNumber: "+11234567890",
  emailVerified: true,
  password: "newPassword",
  displayName: "Jane Doe",
  photoURL: "http://www.example.com/12345678/photo.png",
  disabled: true
})
  .then(function(userRecord) {
    // See the UserRecord reference doc for the contents of userRecord.
    console.log("Successfully updated user", userRecord.toJSON());
  })
  .catch(function(error) {
    console.log("Error updating user:", error);
  });

另一方面,如果您指的是“发送密码重置电子邮件”中的重置,那么不,似乎没有通过 Admin SDK 进行重置的简单方法。

关于node.js - 我可以使用 Firebase Admin SDK for Node 重置用户密码吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46404752/

相关文章:

javascript - gulp 错误 : Cannot find module browserify

javascript - Node : async loop that waits between iterations

javascript - 如何在 Google Cloud Function 中获取原始请求正文?

java - 删除或更改 google-services.json 文件

node.js - 使用 Google Cloud KMS 进行 Firebase 实时数据库加密的最佳实践

javascript - Firebase 实时数据库 : orderByChild(). equalTo() 第 4 级嵌套

node.js - 无法使用 Node.js 管理 SDK 将 Firebase 存储中的内容处置覆盖为 'inline'

python - 在 Visual Studio Code 中运行 Node.js,将 python 脚本作为子进程调用并调试它

node.js - 为两个集合设置护照 jwt 策略

Firebase 函数 1.0.0 迁移 : Trouble with custom initializeApp() with Google Service Account credential