Permission denied error during multiple update on Firebase

会有一股神秘感。 提交于 2019-12-07 20:30:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!