So I have two collections in Firestore. One for the users, and one for the products.
A user looks like (taken straight for the db):
users
--1gJZVpJcnQdaZWnbVJUj
----admin: true
----name: xyz
----email: xyz@gmail.com
----etc
A product looks like:
products
--1gJZVpJcnQdaZWnbVJUj
----name: xyz
----desc: xyzxyzxyz
----price: 20.00
----etc
Now, I can’t add a product even though I’m admin… I get FirebaseError: Missing or insufficient permissions.
These are my Firestore rules:
service cloud.firestore {
match /databases/{database}/documents {
match /{documents=**} {
allow read, write: if false
}
match /products/{prodID} {
allow read: if true
allow write: if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.admin == true
}
match /users/{userID} {
allow read, update, delete: if resource.data.id == request.auth.uid
allow create: if true
}
}
}
All of my js code seems to be working fine as I’ve console logged absolutely everything.
Sorry if this all seems overwhelming I’ve been stuck on this for days…
Thanks in advance