UNPKG

mamba-js-framework

Version:

Mamba JS Framework is a web framework to make a rapid development of web front ends based on AngularJS.

31 lines (23 loc) 852 B
(function () { angular .module('App') .run(runBlock); runBlock.$inject = ['$rootScope','$stateParams', '$state', 'AuthService', '$window']; function runBlock($rootScope, $stateParams, $state, AuthService, $window) { // AuthService._csrfToken().then(function(token){ // AuthService._setCsrfToken(token) // }) $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState) { var requireLogin = toState.data.requireLogin; if(toState.external){ event.preventDefault(); $window.open(toState.url, '_new'); } if (toState.data.requireLogin && AuthService.isAuthenticated() === false) { $state.go("login") event.preventDefault(); } }); } })();