I have the following rules which should allow me to read a document, but I get insufficient permission error. Any advice?
The current user has a document under a collection named users with a field named role that has the value admin
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId}/tickets/{ticketId} {
allow update, delete, create: if false
allow read: if get(/users/$(request.auth.uid)).data.role == "admin"
}
match /users/{userId} {
allow delete:
if false
allow read, write:
if request.auth != null && request.auth.uid == userId
allow update:
if resource.data.points == request.resource.data.points && request.auth != null && request.auth.uid == userId
}
iOS code fetching data
func fetchTickets(contestId: String) -> SignalProducer<[Ticket], FetchError> {
Firestore.firestore()
.collection("users/*/tickets")
.whereField("contest.id", isEqualTo: contestId)
.getDocuments()
}
users collection
{
"role": "admin"
}
users.{userId}.tickets collection
{
"contest": {
"id": ""asdasd
}
}