0
votes

How to use Auth uid that store from firebase and update Auth user information such as change password, email and phone number? I have upload Auth ID into the firebase, then I trying to use snapshot to get the Auth id and apply into the firebase.auth to update the information from auth, but it comes with error.

           firebase.database().ref('users/Admin/'+id).once('value').then(function (snapshot){
        var Authid = snapshot.val().AuthId;
          console.log(Authid);
           
                firebase.auth().updateUser(Authid,{
                email: email,
                password:password,
                phoneNumber:phone, 
        
                }).then((userRecord) => {
                // See the UserRecord reference doc for the contents of userRecord.
                console.log('Successfully updated user', userRecord.toJSON());
                console.log(Authid);
                })
                .catch((error) => {
                    console.log('Error updating user:', error);
                });
                    
    
                });

error

1
Hey Yun Song. Did you get anywhere with this? I tried to help with an answer below. Did you see that, and did it make sense?Frank van Puffelen

1 Answers

0
votes

The updateUser function that you're trying to call is only available in the Admin SDK for Firebase, which is the SDK you'd use in a trusted environment.

Using the client-side SDK it is only possible to update select profile information of the current users. Anything else would be a security risk, as it'd allow any user to update any other user's profile information - or their own sensitive information (such as whether their account is enabled.

If you want to learn what information about the currently signed-in user you can update from this code, have a look at the documentation on updating the user's profile.