【发布时间】:2017-04-20 23:32:26
【问题描述】:
我的数据库权限有问题。
我有以下权限:
"products_invisible": {
"$pid": {
".read": true,
".write":
true,//"auth != null && (root.child('users').child(auth.uid).child('user').child('admin').val() == true)",
".validate": "newData.child('quantity').val() >= 0",
},
".read": true,
}
"products_visible": {
"$pid": {
".read": true,
".write":
true,//"auth != null && (root.child('users').child(auth.uid).child('user').child('admin').val() == true)",
".validate": "newData.child('quantity').val() >= 0",
},
".read": true,
}
"products": {
"$pid": {
".read": true,
".write":
true,//"auth != null && (root.child('users').child(auth.uid).child('user').child('admin').val() == true)",
".validate": "newData.child('quantity').val() >= 0",
},
".read": true,
}
我正在尝试推送一些数据:
var productData = {
<some data>
};
// Get a key for a new Post.
var newProductKey = firebase.database().ref().child('products').push().key;
var updates = {};
updates['/products/' + newProductKey] = productData;//all products
//we also need to add product to other db tables
if(!vm.newProduct.visibility) {
updates['/products_invisible/' + newProductKey] = productData;
}
//visible products table
else if(vm.newProduct.visibility) {
updates['/products_visible/' + newProductKey] = productData;
}
//update
firebase.database().ref().update(updates);
但是,我看到以下错误,不知道为什么。我在这里错过了什么吗?
firebase.js:281 FIREBASE WARNING: update at / failed: permission_denied L @ firebase.js:281(anonymous function) @ firebase.js:454(anonymous function) @ firebase.js:386g.wd @ firebase.js:387qg.wd @ firebase.js:377(anonymous function) @ firebase.js:375cg @ firebase.js:359La.onmessage @ firebase.js:358
firebase.js:458 Uncaught (in promise) Error: PERMISSION_DENIED: Permission denied(…)
【问题讨论】:
-
您正在更新
/products,您似乎没有权限。
标签: javascript firebase firebase-realtime-database firebase-security