持续的认证规定火力地堡 [英] persistent authentication states Firebase

查看:347
本文介绍了持续的认证规定火力地堡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说,我已经配置了我写的规则到一个特定的电子邮件

Lets say I've configured my write rules to a specific 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 ,我用它来增加新项目我的收藏:

I have a newCtrl that I use to add new items to my collection:

.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


  • 如何创建的在我的整个应用程序后的记录
  • 持久验证状态
  • 如何删除的在我的整个应用程序后,一个持久的验证状态的退出

  • How do I create a persistent authentication state across my entire application after logging in?
  • How do I remove a persistent authentication state across my entire application after logging out?

推荐答案

您的认证状态是基于会话的,不依赖于你的控制范围,所以你已经有一个持续验证状态在您的应用程序。

Your authentication state is session-based, not dependent on your controller scope, so you already have a "persistent authentication state" across your application.

必须有别的东西与你的code所产生的错误怎么回事,但就你的问题的话,你可以看到一个工作示例的这里使用 example@example.com 作为电子邮件和例如作为密码。

There must be something else going on with your code that is generating that error, but as far as your question goes, you can see a working example here using example@example.com as the email and example as the password.

我符合你的安全规则一样,所以,如果您登录,而不是作为 test@example.com ,密码测试你将无法创建项目

I matched your security rules as well, so if you login instead as test@example.com with password test you won't be able to create items.

这篇关于持续的认证规定火力地堡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆