After my search for this problem, I found the following , making me believe that this should not be a problem, so I am sure that I am doing something wrong but just can not solve it.
Sometimes, when I go to my application after my authentication expires, it will load the page instead of redirecting to / login, and in the console I see:
Error: permision denied at /the/firebase/url: Client doesn't have permission to access the desired data
If I reload the page, I will be successfully redirected to / login as expected.
angular.module('app',['firebase','ngRoute','ngAnimate','ui.bootstrap']) .factory("Auth",function($firebaseAuth){ var ref = new Firebase("https://app.firebaseio.com"); return $firebaseAuth(ref); }) .run(['$rootScope','$location','$window',function($rootScope,$location,$window){ $rootScope.$on('$routeChangeError',function(event,next,previous,error){ $location.path('/login'); }); if($window.localStorage.getItem('app-last-list')) { $location.path('/lists/' + $window.localStorage.getItem('app-last-list')); } }]) .config(['$routeProvider',function($routeProvider){ $routeProvider .when('/',{ templateUrl: 'views/list-view.html', controller: 'ListViewController', resolve: { "currentAuth": ['Auth', function(Auth) { return Auth.$requireAuth(); }] } }) .when('/login',{ templateUrl: 'views/login-view.html', controller: 'LoginController' }) .when('/lists/:id', { templateUrl: 'views/list-items-view.html', controller: 'ListItemsController', resolve: { "currentAuth": ['Auth',function(Auth){ return Auth.$requireAuth(); }], "list": ['$route','dao',function($route,dao){ return dao.getPrivateList($route.current.params.id).$loaded(); }], "items": ['$route','dao',function($route,dao){ return dao.getListItems($route.current.params.id).$loaded(); }] } }) .otherwise( {redirectTo: '/' }); }]);