2017-10-19 99 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

謝謝,我錯過了文檔的部分 –

相關問題