googlearchive / angularfire-seed

Seed project for AngularFire apps
http://angularfire.com
MIT License
409 stars 191 forks source link

Firebase warning on logout #51

Closed mkv27 closed 10 years ago

mkv27 commented 10 years ago

Hi I see a warning on logout from account section. The warning is only displayed when the ngShowAuth or ngHideAuth directives is used, for example in partial home.html.

If this section does not charge the warning never displayed. Otherwise if I login, then go to home section, then go account and logout. The warning is displayed.

I think the problem is related to the "watch" method in the "simpleLogin" factory.

Warning: firebase-angular-seed

Related "app/js/directives.js": directive firebase

katowulf commented 10 years ago

This is incidental. It's caused by the profile object declared in AccountCtrl. When the login session is terminated, the object cannot access the profile data any longer.

This could be prevented by wrapping the logout function and tracking all active connections to secured data, then calling $off on each before calling logout. I'm not really interested in adding that to the seed as this is more of an implementation-specific and opinionated approach.

mkv27 commented 10 years ago

Thanks for clarification. I only have a little doubt, why if I $destroy the object in AccountCtrl whenever the scope is destroyed the warning no longer appears?

$scope.$on("$destroy", function() {
    profile.$destroy();
});

I really appreciate your help : ]

katowulf commented 10 years ago

That works in this case because we redirect to the login screen when the logout button is clicked (without waiting for the auth to be canceled). It won't work in all cases, but would work here.