Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
197
rated 0 times [  200] [ 3]  / answers: 1 / hits: 33477  / 8 Years ago, wed, september 21, 2016, 12:00:00

I currently have a function that creates a user account. I'd like to be able to add a username field too, but I can't seem to figure out how to update that. I noticed in the Google console, that there is a displayName field that is set to null. I don't know how to change it. This is what I have:



function create(email, password, username) {
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
$timeout(function() {
var errorCode = error.code;
var errorMessage = error.message;
console.log(errorCode.toUpperCase() + : + errorMessage);
})
});
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
$timeout(function() {
console.log(Success! Account Created!);
user.displayName = username; /* this doesn't work*/
});
} else {}
});
}

More From » firebase

 Answers
24

firebase.auth.Auth gives you a firebase.User. You should check out the methods you can run on User: https://firebase.google.com/docs/reference/js/firebase.User



Seems like you're looking for updateProfile: https://firebase.google.com/docs/reference/js/firebase.User#updateProfile


[#60659] Saturday, September 17, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kylanalis

Total Points: 438
Total Questions: 85
Total Answers: 102

Location: Barbados
Member since Sun, Nov 27, 2022
1 Year ago
kylanalis questions
Sat, Oct 2, 21, 00:00, 3 Years ago
Tue, Oct 13, 20, 00:00, 4 Years ago
Thu, Feb 13, 20, 00:00, 4 Years ago
Tue, Jan 7, 20, 00:00, 4 Years ago
;