I am trying to route all unauthorized traffic to the login page, and am using angularfire to authenticate. Here's all the relevant code. I know most of it is broken, but I'd like to get past this first. The problematic code is:
App.js
app.run(['$rootScope', '$location', 'AuthenticatorService', function ($rootScope, $location, AuthenticatorService) {
$rootScope.$on('$routeChangeStart', function (event) {
if (AuthenticatorService.isLoggedIn) {
console.log('DENY');
event.preventDefault();
$location.path('/login');
}
else {
console.log('ALLOW');
$location.path('/home');
}
});
}]);
You had missed couple of things in your code
ng-app
should beng-app="BillingApp"
instead ofng-app="App"
$rootScope
reference in service DI array.Code
Plunkr Here