小编Vin*_*der的帖子

Exists() 不适用于第二个变量 Cloud Firestore 规则

在我的项目中,我想通过检查用户的 uid 是否是该文档的子集合(包含该文档的所有成员)的一部分来控制对文档的访问。当我想用exists() 方法检查这个时,它在它应该授予的时候没有授予权限。

 match /events/{season}/events/{code} {
    function isVV (season, code) {
      return exists(/databases/$(database)/documents/events/$(season)/events/$(code)/vv/$(request.auth.uid));
    }

    allow read: if isVV(season, code);
Run Code Online (Sandbox Code Playgroud)

当我用我当前正在测试的值替换 $(code) 时,规则通过,一切都按预期工作。当我使用变量时,它不会。

任何可以帮助我的 Cloud Firestore 规则专家?也许有更好的方法来做到这一点?

firebase firebase-security google-cloud-firestore

1
推荐指数
1
解决办法
703
查看次数