I'm having a simple blog application. I defined some states for the routing and also defined that on each state-change event it will check the authentication level (in a very naive manner for now) and if the user is allowed to go to this state or not.
app.run(function($rootScope, $state, UserService){
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){
if (!UserService.getCurrentUser()){
$state.go('app.login');
}
});
My JS entry point include this configuration:
app.config(function($stateProvider, $urlRouterProvider){
$stateProvider.state('app', {
url: '',
abstract: true
});
});
I want that when ever going into my application the main route will be the blogs "feed" (and of course when trying to get there it will also fire the $stateChangeStart event so that the authentication will be verified. How can I achive that?