title: Firebase Database Rules - Get displayName
body: <p>I added Firebase to my website and created a signup form.
  When the user clicks the "signup" button it creates a user using "Firebase Authentication", then it updates the user's displayName, and finally adds some data about the user to the database:</p>
  
  <pre><code>firebase.auth().createUserWithEmailAndPassword(email, password).then(function () {
  
      profile = firebase.auth().currentUser;
  
      profile.updateProfile({
         displayName: "name-value"
      }).then(function() {
  
          // Update successful.
  
          firebase.database().ref("/users/" + profile.uid).set({
              data:{
                  country: "country-value",
                  city: "city-value"
              }
          });
      });
  }).catch(function(error) {
      // Handle Errors here.
  });
  </code></pre>
  
  <p>Everything worked fine until I changed the database rules from:</p>
  
  <pre><code>{
      "rules": {
          ".read": true,
          ".write": true
          }
      }
  }
  </code></pre>
  
  <p>To:</p>
  
  <pre><code>{
      "rules": {
          "users": {
              ".read": true,
              "$user": {
                  ".write": "auth.token.name !== null"
              }
          }
      }
  }
  </code></pre>
  
  <p>I used <strong>auth.token.name</strong> as it is written in the <a href="https://firebase.google.com/docs/reference/security/database/#authtoken" rel="nofollow noreferrer">guide</a> to check whether or not the user's displayName exists (I planned to make it check some more things about it later).
  Somehow "firebase rules" 'thinks' that <strong>auth.token.name</strong> equals null, even though I set the displayName before. Why is it happening and what can I do to make it work?</p>
  
  <p>Thanks in advance :)</p>