【发布时间】:2013-11-06 19:58:29
【问题描述】:
假设我已将写入规则配置为特定的email:
{
"rules": {
".read": true,
".write": "auth.email == 'example@example.com'"
}
}
我使用angularFireAuth 服务登录:
.controller('loginCtrl', ["$scope", "$rootScope", "angularFireAuth", function($scope, $rootScope, angularFireAuth) {
var ref = new Firebase("https://test.firebaseio.com/");
angularFireAuth.initialize(ref, {scope: $scope, name: "user"});
$scope.cred = {};
$scope.signin = function() {
angularFireAuth.login('password', {
email: $scope.cred.user,
password: $scope.cred.password,
rememberMe: true
});
}
}]);
我有一个 newCtrl 用于将新项目添加到我的收藏:
.controller('newCtrl', ["$scope", "$rootScope", "angularFireCollection", function($scope, $rootScope, angularFireCollection) {
var ref = new Firebase("https://test.firebaseio.com/");
$scope.items = angularFireCollection(ref);
}]);
当我在我看来调用items.add() 时:
<input type="text" ng-model="item.name" />
<input type="text" ng-model="item.desc" />
<button ng-click="items.add(item)">submit</button>
即使通过loginCtrl成功登录后,我也会收到Not Authorized的回复
- 我如何创建在我的整个应用程序中登录后的持久身份验证状态?
- 注销后,如何删除整个应用程序的持久身份验证状态?
【问题讨论】:
-
您能发布您的安全规则吗?
-
您使用的是正确的 Firebase 网址吗?这个seems to work给我。
-
很抱歉,如果没有身份验证凭据将无济于事,请使用
example@example.com作为电子邮件地址和example作为密码。
标签: angularjs firebase angularfire firebase-security