Suppose there are two documents that
/orgs/foo
/users/alice
and /users/alice has a reference-type field org which references /orgs/foo.
/orgs/foo should be accessible when request.auth.uid == 'alice'. How can I do that?
I guess it is something like this, but I cannot figure out. In other words, how can I get the ID of the referenced document?
function isOrgMember(orgId) {
return get(/databases/$(database)/documents/users/$(request.auth.uid)).data.org.__id__ == orgId;
}
match /orgs/{orgId} {
allow read: isOrgMember(orgId);
}