javascript - 更改规则时,Firebase 数据库权限被拒绝
问题描述
更新这样的规则后,我无法在反应本机应用程序中访问 firebase 数据库
{
"rules": {
"main_data":{
"$uid": {
"xx1":{
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid",
},
"xx2":{
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid",
}
},
},
}
}
我有像这样的json结构
main_data:{
{"uid":{
"xx1":{"id":"uid","d2":"val2","d3":"val3","d4":"d4","d5":"val5","d6":"val6"}
},
"xx2":"value"}
}
我在反应本机应用程序中遇到了这个错误
@firebase/database: FIREBASE WARNING: update at /main_data/UID failed: permission_denied
我通过以下代码访问它
firebase.database().ref('main_data').child(UID).child("xx1 or xx2")
.on("value", data=>{
console.log(data)
})
更新 :我忘了分享写代码
firebase.database().ref('main_data/' + UID).update({
xx2: "Some_value",
}).then(() => {
console.log("Success!!")
}).catch((e) => {
console.log(e)
})
解决方案
我在浪费时间后解决了它,实际上是我在项目中使用的包不匹配问题
推荐阅读
- java - 反射获取特定类中带注释的所有方法
- jenkins - 如何在 Jenkins 流水线中为不同阶段设置不同的分支
- java - testNG中@BeforeTest方法的执行顺序
- python - 获取虚拟环境python包安装日期的方法
- android - Flutter:firebase_auth null 对象引用错误
- autocomplete - 修改调试控制台自动完成
- javascript - 如何使 div 内容(可能是输入、单选、复选框、数字滑块、下拉菜单等)只读并在单击按钮时启用?
- php - 使用模块结构从 Laravel 5.4 中的另一个目录扩展布局
- php - 弹性搜索产品过滤器
- python - python在文件中查找具有最多正则表达式匹配出现的部分