Created
July 17, 2014 00:32
-
-
Save romuloctba/0a9eafd2fe6dd3df5c1e to your computer and use it in GitHub Desktop.
Checking for authentication in AngularJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.run(function ($location,$rootScope,AuthenticationService, FlashService, $templateCache){ | |
var routesThatRequireAuth = ['/main']; | |
$rootScope.$on('$stateChangeStart', function(event,next,current){ | |
if(_(routesThatRequireAuth).contains($location.path()) && !AuthenticationService.isLoggedIn()) { | |
$location.path('/login'); | |
FlashService.info("Por favor efetue login para continuar."); | |
} | |
}); | |
}); | |
//by leonardo.frangelli do grupo fb.com/groups/angularjsbrasil/428371040637355/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment