当我使用 时".read": "auth != null"
,在无错误完成ref.on()
后引发权限ref.auth()
错误。只要用户登录,授予读取权限的正确方法是什么?
安全规则:
{
"rules": {
".read": "auth != null",
".write": "auth.admin == true"
}
}
这是在我对其执行“on()”之前返回给我 Firebase ref 的代码:
ref: function(path) { var self = this;
var ref = new Firebase(self.url + path);
ref.auth(self.auth_token, function(err) {
if (err && console) console.log("Firebase "+path+" login failed!");
else if (console) console.log("Firebase "+path+" login succeeded.");
});
return ref;
},
bind: function(path, excludes) { var self = this;
var collection = [];
var ref = self.ref(path);
...
var move_callback = function(data, prevId) {
$timeout(function() { moveItem(data, prevId); });
}
ref.on('child_added', move_callback);
ref.on('child_changed', move_callback);
ref.on('child_moved', move_callback);
ref.on('child_removed', function(data) {
$timeout(function() { removeItem(data); });
});
return collection;
},
主控制器:
$scope.list = $$firebase.bind("/data", []);
控制台说
Firebase /data login succeeded. app.js:298
FIREBASE WARNING: on() or once() for /data failed: permission_denied firebase.js:33