I can't understand why I get permission denied error for below code.
stream = FirebaseFirestore.instance
.collection('events')
.doc(widget.event.id)
.collection('invitations')
.snapshots();
match /events/{eventId} {
match /invitations/{email} {
allow read: if
request.auth.token.email == email ||
request.auth.token.email == get(/databases/$(database)/documents/events/$(eventId)).data.user_id;
}
}
I can't understand why I get permission denied error for below code.
stream = FirebaseFirestore.instance
.collection('events')
.doc(widget.event.id)
.collection('invitations')
.snapshots();
match /events/{eventId} {
match /invitations/{email} {
allow read: if
request.auth.token.email == email ||
request.auth.token.email == get(/databases/$(database)/documents/events/$(eventId)).data.user_id;
}
}
Share
Improve this question
edited Mar 10 at 17:01
Frank van Puffelen
601k85 gold badges890 silver badges860 bronze badges
Recognized by Google Cloud Collective
asked Mar 10 at 15:43
supercrissysupercrissy
134 bronze badges
1 Answer
Reset to default 0Your query is demanding all of the documents in a subcollection called "invitations", but your rules for that collection require that the query can only request individual documents whose ID is equal to request.auth.token.email
or a field in a different document.
Firebase security rules are not filters (you should read this documentation and understand what it's saying). Rules will not look at each document and figure out which ones the user may find. The rules require that the query request only the specific documents that are allowed by the rule, which means you code should only get()
a single document that meets the rules requirements.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744837204a4596336.html
评论列表(0条)