title: Firestore security rule logging of variable values
body: <pre><code>service cloud.firestore {
    match /databases/{database}/documents {
  
     match /companies/{companyName=**}{
          allow read,write: if isUserAuthorized(companyName,get(/databases/$(database)/documents/companies/$(companyName)/users/$(request.auth.uid)).data.company) == true;
     }
    }
  }
  function isUserAuthorized(requestedCompanyName,userCompanyName) {
    return requestedCompanyName == userCompanyName;
  }
  </code></pre>
  
  <p>In the above rule of firestore I am trying to make sure that only employees from a company can access data of that company. The data structure on firestore looks like the following screenshot.
  where data is saved in this path /companies/{companyName}/users/{uid}/company</p>
  
  <p><a href="https://i.stack.imgur.com/2PVpn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2PVpn.png" alt="enter image description here"></a></p>
  
  <p>But when I try to save I get <code>Error: Missing or insufficient permissions.</code> js error. </p>
  
  <ul>
  <li>Is there anything apparent I am doing wrong?</li>
  <li>Is there any logging that happens on firestore side where I can see what request was made and what were the values of variables used in the rules.</li>
  <li>Or is there a way to test the rules?</li>
  </ul>