Showing posts with label AngularJS Login and Authentication in each route and controller. Show all posts
Showing posts with label AngularJS Login and Authentication in each route and controller. Show all posts

AngularJS Login and Authentication in each route and controller

Use below code: 

 app.run(function($rootScope, $state, localStorageService) {
  $rootScope.$on('$stateChangeStart', function(event, current) {
      if (current.url != '/login' && current.url != '/signup' &&
              current.url != '/createPassword' && current.url !=
                  '/forgotPassword' && localStorageService.get('user') == null) {
          event.preventDefault();
          $state.go('login');
      }
  })
});