I am trying to make my read
rules working in RTDB as follow :
{
"rules": {
"test": {
"$uid": {
".read": "data.exists()",
}
},
}
}
Here is the data in test
node :
{
"test" : {
"anyuid" : {
"content" : {
"uid1" : "gnjdssd",
"uid2" : "fnvdjkcx"
},
"at" : "2491795"
}
}
}
Here is my code that is denied (actually tested with and without orderByChild
but in my real query i need the orderByChild
so if this changes anything in the rule except the .indexOn i prefer to specify it) :
FirebaseDatabase.instance.ref().child("test").orderByChild("at").get()
The log : I/RepoOperation(29129): get for query /test falling back to disk cache after error: Permission denied
My goal is to allow read if there is a real condition such as :
data.child('content/'+auth.uid).exists()
But the data.exists()
is is not reached in this case.
What i am missing here and how can i implement the rule i want please ?
EDIT :
my data structure is :
{
"chats": {
"$chatID": {
members: {
"userID1": true,
"userID2": true,
}
}
}
}
I want to allow userID1
to read only chats
where his id
is actually in the member
map of the chat
.