【发布时间】:2017-03-07 04:05:05
【问题描述】:
这是我第一次使用 firebase,当我尝试检索数据时却无法正常工作。
我已经实现了 firebase 的授权并使用了它,现在可以从任何控制器(检查下面的控制器)查看用户的数据,但是当我尝试从数据库中检索数据时出现此错误:
permission_denied at /: Client doesn't have permission to access the desired data.
我关于提要的数据库规则是:
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
如果我将它们公开,它会起作用并且我会获取数据,但我不想这样做,而且我在网上找不到任何关于如何发送用户 ID 以从 firebase 获取数据的文档。
我的控制器:
.controller('homeCtrl', ['$scope','$firebaseObject','currentAuth',
function($scope,$firebaseObject,currentAuth) {
console.info('currentAuth',currentAuth); // This returns the needed info about the current user including the uid
// This is where I get the permission denied error.
var ref = firebase.database().ref();
// download the data into a local object
$scope.data = $firebaseObject(ref);
}]);
感谢您的帮助。
【问题讨论】:
标签: angularjs firebase angularfire