Reputation: 4116
This is my firebase json data.
{
"Users": {
"MyData": {
"002ab7bUmab1CgQsw53abB3g1Ab1": { //UID
"-A3ABlabkflA_ABabABA": { //this is the databaseReference.child(DBHelper.FIREBASE_POSTS).push().getKey();
"display": "123",
"result": {
"format": "1",
"id": 1,
"numBits": 0,
"syncFirebaseId": "-A3ABlqmkflA_AVabABA",
"syncStatus": -1,
"text": "1234567",
"timestamp": 1514496903005
}
},
"-A2ABlabkf2A_ABabABA": { //this is the databaseReference.child(DBHelper.FIREBASE_POSTS).push().getKey();
"display": "123",
"result": {
"format": "1",
"id": 1,
"numBits": 0,
"syncFirebaseId": "-A3ABlqmkflA_AVabABA",
"syncStatus": -1,
"text": "1234567",
"timestamp": 1514496903005
}
}
}
}
}
}
Rules:
{
"rules": {
"Users": {
"MyData": {
"$uid": {
".read": "auth != null && auth.uid == $uid"
}
}
}
}
}
But when I simulate, read operation is denied. I want to allow only authenticated user to update data node that is relevant to his/her own. That user should not be able to edit other's data node (UID).
Here is the result of read simulation:
Upvotes: 0
Views: 223
Reputation: 598817
You're trying to read the root of your database. Since your rules grant nobody access to the entire database, the read is rejected. If you simulate reading from /Users/MyData/$theUidThatYouStruckOut
it will be allowed.
Upvotes: 1
Reputation: 21
You have change Rules
{
"rules": {
"Users": { *** This Line
"MyData": {
"$uid": {
".read": "auth != null && auth.uid == $uid"
}
}
}
}
}
Upvotes: 0
Reputation: 1019
I think auth.uid == $uid"
should be auth.uid === $uid"
. For more information go through this
Upvotes: 0