Firebase security rules with wildcards

前端 未结 1 965
北海茫月
北海茫月 2021-01-06 14:36

I\'ve got a data structure like this:

How can I access /Restaurant/-KK37k6g5cYYippEHpZ3/User/-KK37k6g5cYYippEHpZ4/id\'s value within the fireba

相关标签:
1条回答
  • 2021-01-06 14:41

    Not sure if I fully understood what you are asking for but here goes my thoughts.

    The first problem in your rule is that you are specifying child($id) but you already are inside the $id. it is implicit in your data that you are referring to $id.

    To resolve your main problem you wont need another wildcard. You can just use hasChild to verify if the auth.uid is inside restaurant/user.

    "Restaurant": {
       "$id": {
          ".read": "auth.uid != null",
          ".write": "auth.uid != null && data.child('User').hasChild(auth.uid)"
       }
    }
    
    0 讨论(0)
提交回复
热议问题