In my firestore DB, there is a field playerCount = 1
(int type) and isStarted = true
(boolean type)
Below are my firestore rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /props/{propId} {
allow list,write,create: if false;
allow read: if isLoggedIn() && propId=="7Ia********iqDO";
}
match /rooms/{roomId=**} {
allow create: if isLoggedIn();
allow read, list: if roomData("KjUXL49I1XVlXDGZ8jqL").playerCount==1 || resource.data.playerCount == 1 || oldData().isStarted || authData().uid in oldData().accessIds;
allow write: if authData().uid in oldData().accessIds;
}
}
function isLoggedIn() { return authData() != null;}
function authData() { return request.auth }
function oldData() { return resource.data }
function newData() { return request.resource.data }
function roomData(roomPath) { return get(/databases/$(database)/documents/rooms/$(roomPath)).data }
}
From Android App, I am querying the below code:
FirebaseFirestore.getInstance().collection("rooms").whereEqualTo("roomId", "023340").limit(1).get(Source.SERVER).addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if(task.isSuccessful()){
ArrayList a = (ArrayList)task.getResult().getDocuments().get(0).getData().get("accessIds");
Log.d("sdccddsdcswc", String.valueOf(a.size()));
} else {
toast("Failed to read Room");
}
}
});
Now the PROBLEM is:
I am always getting Permission Denied error.
I would like to know why "resource.data.isStarted"
& "resource.data.playerCount" are not being read.