title: Uncaught (in promise) FirebaseError: Missing or insufficient permissions when registering client
body: <p>I keep getting this nasty error when I try to register one of my users:</p>
  <blockquote>
  <p>Uncaught (in promise) FirebaseError: Missing or insufficient permissions when registering client</p>
  </blockquote>
  <p>Here is the code that facilitates my registration process:</p>
  <pre class="lang-js prettyprint-override"><code>const user = await db.collection(&quot;public&quot;).doc(username).get();
      if (user.data()) {
      }
      try {
        const authUser = await auth.createUserWithEmailAndPassword(
          email,
          password
        );
        if (authUser) {
          await db.collection(&quot;private&quot;).doc(authUser.user.uid).set({
            username: username,
          });
          await db
            .collection(&quot;public&quot;)
            .doc(username)
            .set({
              userId: authUser.user.uid,
              profileInfo: {
                imageUrl: &quot;&quot;,
                displayName: username,
                bio: &quot;&quot;,
                location: &quot;&quot;,
              },
            });
  
          await dispatch({
            type: &quot;SET_USER&quot;,
            user: {
              uid: authUser.uid,
              username,
            },
          });
          history.push(&quot;/dashboard&quot;);
        }
      } catch (error) {
       
      }
    };
  </code></pre>
  <p>And here are my firebase rules:</p>
  <pre><code>rules_version = '2';
  service cloud.firestore {
    match /databases/{database}/documents {
      match /{document=**} {
        allow write, update, delete, create, read: if false;
      }
      match /public/{username} {
        match /{document=**} {
          allow create, write, update, delete: if request.auth != null &amp;&amp;
          get(/databases/$(database)/documents/private/$(request.auth.uid)).data.username == username;
          allow read: if true;
      }
    }
    match /private {
        match /{uid}/{document=**} {
          allow write, update, delete, create, read: if request.auth != null &amp;&amp;
          request.auth.uid == uid;
        }
      }
    }
  
  }
  </code></pre>
  <p>Any idea what this particular code is causing this error?</p>
  <p>What's weird is that when I refresh the page, I am able to access <code>/dashboard</code> and make all of my normal updates just like a logged in user should.</p>