Prevent items in scope from writing to a different user's records

前端 未结 2 1229
名媛妹妹
名媛妹妹 2021-01-03 15:52

I was having success with using AngularFire in a scenario where there is one user on my application.

Now that I have authentication up and running, I\'m noticing tha

2条回答
  •  臣服心动
    2021-01-03 16:57

    You need to unbind $scope.items on logout. The best way to do this will be to save the unbind function given to your promise in $scope:

    var ref = new Firebase('https://.firebaseio.com/items/[user1id]');
    angularFire(ref, $scope, 'items').then(function(unbind) {
      $scope.unbindItems = unbind;
    });
    
    $scope.$on('angularFireAuth:logout', function() {
      $scope.unbindItems();
    });
    

提交回复
热议问题