flutter - Can't understand why get Permission denied error - Stack Overflow

I can't understand why I get permission denied error for below code.stream = FirebaseFirestore.ins

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
Add a comment  | 

1 Answer 1

Reset to default 0

Your 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信