我正在使用Firebase云身份验证创建一个简单的门户网站。一个用户是管理员,他将创建其他普通用户并将凭据移交给普通用户。
var newUser = firebase.auth().createUserWithEmailAndPassword(newEmail, newPassword);
现在我希望管理员应该可以选择为任何普通用户重置密码。
我怎样才能做到这一点?任何人都可以分享任何想法。
谢谢!
可以通过在
管理 SDK 中调用 updateUser()
来执行此操作。本文档页面中的示例:
admin.auth().updateUser(uid, {
email: "modifiedUser@example.com",
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);
});
此功能目前仅在 Node.js 版本的管理 SDK 中可用。