title: How to add username with email and password in Firebase?
body: <p>I'm using Firebase and I'm trying to add a username to the database with the email and password. </p>
  
  <p><img src="https://i.stack.imgur.com/Jtpqw.png" alt="This is how my database look like now"></p>
  
  <p>Is there a way to do it or is <code>createUserWithEmailAndPassword()</code> function only for email and password?</p>
  
  <pre><code>signUp.addEventListener("click", function(user)
  {
      var username = usernameTxt.value;
      var email = emailTxt.value;
      var password = passwordTxt.value;
  
      firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error)
      {
  
  
        // Handle Errors here.
        var errorCode = error.code;
        var errorMessage = error.message;
  
        if (errorCode == 'auth/email-already-in-use')
        {
              alert('email-already-in-use.');
          }
          else
          {
              alert(errorMessage);
          }
            console.log(error);
  
      });
  });
  </code></pre>
  
  <p>The solution that i found to how to add username with the createUserWithEmailAndPassword() function:</p>
  
  <pre><code>firebase.auth().onAuthStateChanged(function(user) {
  
    var username = usernameTxt.value;
  
    if (user) {
      firebaseDataBase.ref('users/' + user.uid).set({
          email: user.email,
          uid : user.uid,
          username: username
      });
  
  
      console.log("User is signed in.");
    } else {
       console.log("No user is signed in.");
  
    }
  });
  </code></pre>