Firebase (web) - Add User Data Upon Signup
I am having some troubles with the following case: I am using email login functionality in Firebase Auth. Everything works fine. As part of the registration form however, there is
Solution 1:
I think you could try this
firebase.auth().createUserWithEmailAndPassword(email, password).then(function(user) {
var user = firebase.auth().currentUser;
user.updateProfile({
displayName: name
}).then( ()=> {
alert(user.displayName + " " + user.email);
})
});
Edit 1:
- I forgot ")" at the end
- add
.then
to show alert that theuser
is updated. Note: for test purpose disable myfirebase.auth().onAuthStateChanged(..)
so it won't redirect and thealert
will show
Edit 2: Nvm the problem is with onAuthStateChanged
it won't get updated
Solution 2:
An update of a user profile does not result in any auth state listener callbacks to be triggered. Listeners are only invoked when the user is newly signed in or signed out since the last time the listener was invoked. If you need to reload a user's profile after an update, you can call reload() on the user object.
Post a Comment for "Firebase (web) - Add User Data Upon Signup"