Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This issue relates to this bit of code in the file app/js/controllers/headercontroller.js.</p> <pre><code>$scope.$on('angularFireAuth:login', function() { angularFire(new Firebase(FBURL+'/users/'+$scope.auth.id), $scope, 'user'); }); </code></pre> <p>What happens here is that every time <code>angularFireAuth:login</code> get’s $broadcast‘d, we’re hooking up <code>$scope.user</code> to a Firebase ref located at <code>FBURL+'/users/'+$scope.auth.id</code>. Now, the issue is that if you log out, then log back in, <code>angularFireAuth:login</code> gets $broadcast‘d twice. This wouldn’t be an issue except for the fact that we’re spinning up an angularFire in the callback. The result of this is that we now have two <code>angularFire</code>s tied to <code>$scope.user</code>. This means, that if <code>$scope.user</code> gets changed, we’ll write to two separate Firebase ref’s.</p> <p>If we attach an <code>angularFire</code> to <code>$scope.user</code> and, for example <code>$scope.user</code> gets set to <code>{name: "Tyler"}</code>, then when we log out and log back in, the current value of <code>$scope.user</code> gets written to the new <code>angularFire</code>, which is tied to a different user's path. This results in this weird account overwriting behavior.</p> <p>Anyway, the solution is to use the <code>disassociate()</code> method passed when <code>angularFire</code>’s promise is resolved.</p> <p>For example, try this.</p> <pre><code>$scope.$on('angularFireAuth:login', function() { if ($scope.disassociateUserData) { $scope.disassociateUserData(); } angularFire(new Firebase(FBURL+'/users/'+$scope.auth.id), $scope, 'user').then(function (disassociate) { $scope.disassociateUserData = disassociate; }; }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload