In Firebase, how do you update the displayName field of a user in Auth?
<p>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:</p>

<pre><code>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 {}
    });
}
</code></pre>