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.
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