问题
I am using multiple updates feature on Firebase where I have created a object which is updating multiple locations in the database at once. I have given write permissions to each of those locations individually. Here is an example of what I am trying to update on Firebase as part of multiple updates
{
"alarms/298302f2-f95d-4200-b2ca-53dcf5706125/date": 1478141940167,
"userInfos/-KGvMbo5MK-W5q4qgcF0/alarms/298302f2-f95d-4200-b2ca-53dcf5706125": 1478141940167,
"userInfos/-KGvMIPwul2dUY181xLQ/backupForAlarms/298302f2-f95d-4200-b2ca-53dcf5706125": 1478141940167,
"alarms/57656d1f-4c01-4807-93ea-44ab42791140/date": 1479979440107,
"userInfos/-KGvMbo5MK-W5q4qgcF0/alarms/57656d1f-4c01-4807-93ea-44ab42791140": 1479979440107
}
Let's say firebaseUpdateObj
contains the above object. I am using below line of code to perform the update
firebase.database().ref().update(firebaseUpdateObj)
I am seeing the following error on the console
FIREBASE WARNING: update at / failed: permission_denied
I have given write permissions to the alarms
and the userInfos
branch in the rules file and I am able to write at both of these locations using firebase.database().ref().child('alarms').child(alarmId).set(alarm)
and firebase.database().ref().child('userInfos').child(uid).set(userInfo)
. But looks like when I am giving the update command like above, it's trying to check if I have write permission at location /
which I obviously don't.
Is this expected behavior? I am able to run similar update command on the server side but there I have the server permissions, so I guess the rules don't come into picture there. I am using Firebase 3.3.0
.
来源:https://stackoverflow.com/questions/40847602/permission-denied-error-during-multiple-update-on-firebase