This are my rules:
{
"rules": {
"freecoinsrequest":{
".read": false,
".write": "
newData.child('uid').val() == auth.uid
1. && (root.child('users').child(auth.uid).child('/server/lasttimetookfreecoins').val() < now - 10000
2. || !root.child('users').child(auth.uid).child('/server/lasttimetookfreecoins').exists())
" ,
"uid":{
".validate" : true
},
"$other":{
".write": false,
".validate": false
}
},
}
}
So a user should only be able to write to the path if:
- the JSON contains "uid" as a key, and his uid as a value
- He did not write to server/lasttimetookfreecoins within 10 seconds ago OR
- He never wrote to server/lasttimetookfreecoins
I can not understand why it gets denied in the simulator. When I uncomment 1 and 2, as seen in the rules, it works.
Thanks.