Reputation: 1785
my Firebase RTD is structured as follows:
messages :{
userId1: {
userId2: {sentFrom: userId1, messageText: 'hello user 2 from user 1'}
},
userId2: {
userId1: {sentFrom: userId1, messageText: 'hello user 2 from user 1'}
},
}
I want user1 to be able to write to DB if path is message/userId1
.....but I also want user1 to be able to write if path is message/anyOtherUserId/userId1
The json I am using in rules is as per below....and when I hit path message/userId1
its a success...but when I hit message/anyOtherUserId/userId1
it returns "Simulated set denied"
{
"rules": {
"messages": {
"$userId": {
".write": "$userId === auth.uid ? true : (root.child($userId).val()===auth.uid ? true : false)",
},
}
}
}
Upvotes: 1
Views: 136
Reputation: 1286
You may need to further cascade the rules. Try this in your simulation:
{
"rules": {
"messages":{
"$userId":{
".write": "$userId === auth.uid",
"$userIdChild": {
".write": "$userIdChild === auth.uid"
}
}
}
}
}
I hope this helps!!
Upvotes: 3