'use strict'; /* App Module */ var luticate = angular.module('luticate', [ 'ui.bootstrap', 'ui.router', 'luticateUtils', 'luticateAuth', 'LocalStorageModule', 'dialogs.main', 'ngSanitize', 'ui.validate' ]); luticate.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', function($stateProvider, $urlRouterProvider, $httpProvider) { $stateProvider.state('root', { abstract: true, template: '
', resolve: { userData: ['luticateAuthUsers', function(luticateAuthUsers) { return luticateAuthUsers.loadUserData(null); }] } }); $stateProvider.state('login',{ url:'/', parent: 'root', templateUrl:'views/login.html', controller:'LoginController' }); $stateProvider.state('home',{ url:'/home', parent: 'root', templateUrl:'views/home.html', controller:'HomeController' }); $stateProvider.state('users',{ url:'/users', parent: 'root', templateUrl:'views/users.html', controller:'UsersController' }); $stateProvider.state('groups',{ url:'/groups', parent: 'root', templateUrl:'views/groups.html', controller:'GroupsController' }); $stateProvider.state('permissions',{ url:'/permissions', parent: 'root', templateUrl:'views/permissions.html', controller:'PermissionsController' }); $stateProvider.state('settings',{ url:'/settings', parent: 'root', templateUrl:'views/settings.html', controller:'SettingsController' }); $stateProvider.state('test',{ url:'/test', parent: 'root', templateUrl:'views/test.html', controller:'TestController' }); $urlRouterProvider.otherwise('/'); $httpProvider.interceptors.push(['luticateAuthCache', '$injector', '$q', function (luticateAuthCache, $injector, $q) { return { 'request': function (config) { var token = luticateAuthCache.getToken(); if (token != null) config.headers['X-Authorization'] = token; return config; }, 'responseError': function(rejection) { /*if (rejection.status == 401) { luticateAuthCache.removeUser(); $injector.get('$state').transitionTo('login'); }*/ return $q.reject(rejection); } }; }]); }]) .run(['$rootScope', '$state',function ($rootScope, $state) { $rootScope.$on('$stateChangeError', function (e, curr, prev) { //$state.go('login'); }); }]);