Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the displayName of Firebase user?

People also ask

Can you change user uid Firebase?

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.


You have to chain the request:

firebase.auth().createUserWithEmailAndPassword(email, password)
.then(function(result) {
  return result.user.updateProfile({
    displayName: document.getElementById("name").value
  })
}).catch(function(error) {
  console.log(error);
});`

I could´t use ({displayName: name}) directly (sintaxe error in editor). Then, I found another way:

UserUpdateInfo updateInfo = UserUpdateInfo();
updateInfo.displayName = name;
result.user.updateProfile(updateInfo);

This is in Dart (I am using Firebase with Flutter).


firebase
      .auth()
      .createUserWithEmailAndPassword(newUser.email, newUser.password)
      .then((res) => {
        const user = firebase.auth().currentUser;
        return user.updateProfile({
          displayName: newUser.name
        })
      })

This worked for me.