Dear community,
very new to FF and FB and run into a logical problem I dont know what I am doing wrong.
In a collection, named organizations,
/organizations
/{documentID}
name: "Name"
users:
- userId1
- userId2
- userId3
The users should hold usersID from the "users" collection and grant access (read write delete) if the usersID is in this collection. Similar to this: Firestore Rules - FlutterFlow Docs
If I set the rules in FF to
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{document} {
allow create: if request.auth.uid == document;
allow read: if request.auth.uid == document;
allow write: if request.auth.uid == document;
allow delete: if false;
}
match /organizations/{document} {
allow create: if request.auth != null;
allow read: if request.auth != null;
allow write: if request.auth != null;
allow delete: if request.auth != null;
}
}
}
My UI renders all items in the collection, all good.
If I change now the Read Write Delete to Tagged Users
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{document} {
allow create: if request.auth.uid == document;
allow read: if request.auth.uid == document;
allow write: if request.auth.uid == document;
allow delete: if false;
}
match /organizations/{document} {
allow create: if request.auth != null;
allow read: if request.auth.uid in resource.data.users;
allow write: if request.auth.uid in resource.data.users;
allow delete: if request.auth.uid in resource.data.users;
}
}
}
I no longer get any organization back. I added the userID in the organization collection with /users/XXXXXX or just XXXXXXX makes no difference.
What am I doing wrong?