10

This is my error: Error running simulation — Error: simulator.rules line [10], column [13]. Function not found error: Name: [get].; Error: Invalid argument provided to call. Function: [get], Argument: ["||invalid_argument||"]

When i run this i have used all the resources i can find on the web and found nothing that will work (the allow read works and create does when i just use isSignedIn() ) ... little help please.

service cloud.firestore {
 match /databases/{database}/documents{
    match /users/{documents} {     
  function isSignedIn() {
         return request.auth != null;
    }
  function getRole(admin){
     return get(/databases/$(database)/documents/users.[request.auth.uid]).data.admin;     
   }        
     allow read: if true; 
     allow write: if getRole(admin) == true;    
    }
  }  
}

Here is my db

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • 1
    I face similar issues quite frequently. Usually, it's something simple, and then I have to not touch my Firestore rules for fear of breaking them again... Might it have to do with trying to `get()` a document that doesn't exist yet? – AverageHelper May 14 '19 at 00:01

1 Answers1

2

You need to check that user authentificated before trying to get role of user in getRole function. Exception occurs because request.auth.uid is null. Also check that users.[request.auth.uid] is valid path.

WhoKnows
  • 340
  • 1
  • 12