Firebase的文档建议API提供与控制台相同的特性:
为了管理Firebase用户,必须访问Firebase控制台并不总是很方便。管理用户管理API为这些相同的用户提供编程访问。它甚至允许您做Firebase控制台无法做的事情,例如检索用户的完整数据和更改用户的密码、电子邮件地址或电话号码。
但是参考文档没有列出用于重置用户密码的函数。我是不是遗漏了什么?
发布于 2017-09-25 12:05:51
编辑:这个答案现在已经过时了,关于如何通过Firebase .发送密码重置链接,请参阅下面Andrea的答案。
这取决于您所使用的“重置”的定义。
如果您的意思是“更改”中的重置,那么是- 函数允许您提供一个新的密码。请参阅文档中的以下示例:
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这样做的简单方法。
发布于 2020-09-01 10:21:53
可以,停那儿吧。若要生成密码重置链接,请提供现有用户的电子邮件。然后,您可以使用任何电子邮件服务,您喜欢发送的实际电子邮件。链接到文档。
// Admin SDK API to generate the password reset link.
const userEmail = 'user@example.com';
admin.auth().generatePasswordResetLink(userEmail, actionCodeSettings)
.then((link) => {
// Construct password reset email template, embed the link and send
// using custom SMTP server.
return sendCustomPasswordResetEmail(email, displayName, link);
})
.catch((error) => {
// Some error occurred.
});https://stackoverflow.com/questions/46404752
复制相似问题