Skip to content

Instantly share code, notes, and snippets.

@pablodenadai
Last active May 23, 2019 13:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pablodenadai/5954381 to your computer and use it in GitHub Desktop.
Save pablodenadai/5954381 to your computer and use it in GitHub Desktop.
AngularJS: On route change start - Check if user has permission to proceed or redirect it to the Sign In page.
app.run(function ($rootScope, $location, AuthenticationModel) {
// Register listener to watch route changes.
$rootScope.$on('$routeChangeStart', function (event, next, current) {
if (!AuthenticationModel.isSignedIn() && next.requireAuthentication === true) {
$location.path('/signin');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment