I've a web application and I want, as the Admin user, to be able to update the information like displayName
and photoURL
of other users with Firebase
authentication.
Typically if we want to update the user information we use firebase.User.updateProfile()
but that just works for the current user, and, as I've mentioned before, I'm logged in with an admin account and I want to update other users' profiles.
My question is: Is there a function to which you can pass the uid
and the information of an user to be updated?
Thanks.
uid cannot be changed. You can create your own custom uid for users. You will need a users table which uses your custom uid rather than the one created by Firebase.
The admin SDK runs your code with administrative permissions. This means it bypasses the security rules of your Firebase Database. It also has functionality to manage users and mint custom tokens and can be used to send FCM messages.
If the user login with a custom "email/password" you don't know anything else about that user (apart from the unique user id). If a user login with Facebook, or with Google sign in, you can get other information like the profile picture url. It is explained here: firebase.google.com/docs/auth/android/… .
You can do so with the Firebase Admin SDK
:
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);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With