gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 01:24:15 24 4
gpt4 key购买 nike

我有一个 Web 应用程序,我希望作为管理员用户能够更新信息,例如 displayNamephotoURL其他用户的 Firebase验证。

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

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

谢谢。

最佳答案

您可以使用 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);
});

关于firebase - 如何在 Firebase 中将用户更新为管理员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46837992/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com