Firestore rules for matching User in Array stopped working.

Hello! So my firestore rules seem to have broken unexpectedly. I have collection 'decks' and want user tagged in the sharedWith user ref Array to have read access. Unexpectedly my read queries have stopped working. The only changes I made to firebase was add a cloud function and index a new field, so shouldn't affect the rules.

Here are my rules, the create/write/delete all work fine, just read has broken (I've tested with allowing everyone to read and the queries start working again). The Shared with Field is populated correctly.

:

allow read: if /databases/$(database)/documents/users/$(request.auth.uid) in resource.data.sharedWith;

Full rules:

match /decks/{document} {

allow create: if request.auth != null;

allow read: if resource.data.isPublic;

allow read: if /databases/$(database)/documents/users/$(request.auth.uid) in resource.data.sharedWith;

allow write: if resource.data.owner == /databases/$(database)/documents/users/$(request.auth.uid);

allow delete: if resource.data.owner == /databases/$(database)/documents/users/$(request.auth.uid);

}

2
5 replies