2017-10-19 39 views
0

我有一个Web应用程序,我希望作为Admin用户能够使用Firebase身份验证更新其他用户的displayName和photoURL等信息。通常情况下,如果我们想更新用户信息,我们使用firebase.User.updateProfile(),但这只适用于当前用户,正如我在使用管理员帐户登录之前所说的,并且我想更新其他用户配置文件。 我的问题是:是否有一个函数可以传递用户的uid和信息进行更新? 谢谢。如何在Firebase中以管理员身份更新用户

回答

2

您可以用火力地堡联系SDK这样做: https://firebase.google.com/docs/auth/admin/manage-users#update_a_user

admin.auth().updateUser(uid, { 
    email: "[email protected]", 
    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); 
}); 
+0

谢谢,我错过了文档的部分 –

相关问题