Reputation: 3865
I'm sure this is a popular question but I can't find the question/answer!
Uncaught Error in snapshot listener: FirebaseError: Missing or insufficient permissions.
Here's my Firestore rule:
service cloud.firestore {
match /databases/{database}/documents {
match /cars/{document} {
allow read: if request.auth.uid == document.uid;
}
}
}
Upvotes: 0
Views: 281
Reputation: 317958
If you want to refer to document data in rules, the syntax is like this:
allow read: if request.auth.uid == resource.data.uid;
This will work when the client performs a get()
of the individual document, and they are signed in with a UID that matches the uid field of the document.
I suggest reviewing the documentation on authentication and data validation.
Upvotes: 2