Skip to content

Instantly share code, notes, and snippets.

@fnakstad
Created July 18, 2013 20:51
Show Gist options
  • Save fnakstad/6032970 to your computer and use it in GitHub Desktop.
Save fnakstad/6032970 to your computer and use it in GitHub Desktop.
angular.module('angular-client-side-auth', ['ngCookies'])
.run(['$rootScope', '$location', 'Auth', function ($rootScope, $location, Auth) {
$rootScope.$on("$routeChangeStart", function (event, next, current) {
if (!Auth.authorize(next.access)) {
if(Auth.isLoggedIn()) $location.path('/');
else $location.path('/login');
}
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment