Wednesday 15 April 2015

Why can't I change the priority of my Firebase reference (Permission denied) -



Why can't I change the priority of my Firebase reference (Permission denied) -

in firebase, have object looks this:

person ---- name ---- age

when seek create first time, utilize command:

firebaseref.child("person").setvalue(...)

that works fine.

sometimes want create entry priority, , can done this:

firebaseref.child("person").setvalue(..., mypriority)

this works fine well.

however, priority should updated later. tried following:

firebaseref.child("person").setpriority(mypriority)

unfortunately, fails error message "permission denied". why this?

the security rules reference follows:

"person": { ".read": true, ".write": true, "name": { ".validate": "newdata.isstring()" } "age": { ".validate": "newdata.isnumber()" } "$other": { ".validate": false } }

as can seen, node both readable , writeable.

the problem:

the reason "permission denied" error in security rules.

the problem priority stored in "hidden" property .priority mentioned in documentation.

that property not shown in firebase forge (dashboard) can seen when exporting raw json.

now directive "$other": { ".validate": false } prevents property other name , age beingness validated. error "permission denied" raised.

i don't know, however, why object can written in first place when using setvalue(..., mypriority). should cause error well.

the (half-way) solution:

now seems obvious add together new directive security rules looks this:

".priority": { ".validate": true }

but doesn't work. firebase forge responds with:

key names can't contain ".", "#", "$", "/", "[", or "]" (unbound names start "$")

this means cannot solve issue. have adjust our existing security rules drawback: rule "$other": { ".validate": false } has removed when want update priorities, leaving imperfect validation.

firebase firebase-security

No comments:

Post a Comment