如何在 Firebase 中将用户更新为管理员

Luc*_*ero 7 web firebase firebase-authentication

我有一个web应用程序,我想,作为管理员用户,才能够更新信息,如displayNamephotoURL其他用户的Firebase身份验证。

通常,如果我们想更新我们使用的用户信息,firebase.User.updateProfile() 但这仅适用于当前用户,而且,正如我之前提到的,我使用管理员帐户登录,我想更新其他用户的个人资料。

我的问题是:是否有一个函数可以将 uid用户的信息给要更新的信息?

谢谢。

boj*_*eil 9

你可以这样做Firebase Admin SDK

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);
    });
Run Code Online (Sandbox Code Playgroud)