Skip to content

Instantly share code, notes, and snippets.

@afcastano
Created August 21, 2014 02:03
Show Gist options
  • Save afcastano/33f444cbd55e9bd0f255 to your computer and use it in GitHub Desktop.
Save afcastano/33f444cbd55e9bd0f255 to your computer and use it in GitHub Desktop.
Route based authorization for Angular.js
$rootScope.$on('$stateChangeStart', function (ev, to, toParams, from, fromParams) {
if (!authorizationService.isAuthorized($location.url()) {
// redirect to error page
$location.path('/error');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment