You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. 'use strict';
  2. /* App Module */
  3. var luticate = angular.module('luticate', [
  4. 'ui.bootstrap',
  5. 'ui.router',
  6. 'luticateUtils',
  7. 'luticateAuth',
  8. 'LocalStorageModule',
  9. 'dialogs.main',
  10. 'ngSanitize',
  11. 'ui.validate'
  12. ]);
  13. luticate.config(['$stateProvider', '$urlRouterProvider', '$httpProvider',
  14. function($stateProvider, $urlRouterProvider, $httpProvider) {
  15. $stateProvider.state('login',{
  16. url:'/',
  17. templateUrl:'views/login.html',
  18. controller:'LoginController'
  19. });
  20. $stateProvider.state('home',{
  21. url:'/home',
  22. templateUrl:'views/home.html',
  23. controller:'HomeController'
  24. });
  25. $stateProvider.state('users',{
  26. url:'/users',
  27. templateUrl:'views/users.html',
  28. controller:'UsersController'
  29. });
  30. $stateProvider.state('groups',{
  31. url:'/groups',
  32. templateUrl:'views/groups.html',
  33. controller:'GroupsController'
  34. });
  35. $stateProvider.state('permissions',{
  36. url:'/permissions',
  37. templateUrl:'views/permissions.html',
  38. controller:'PermissionsController'
  39. });
  40. $stateProvider.state('test',{
  41. url:'/test',
  42. templateUrl:'views/test.html',
  43. controller:'TestController'
  44. });
  45. $urlRouterProvider.otherwise('/');
  46. $httpProvider.interceptors.push(['luticateAuthCache', '$injector', '$q',
  47. function (luticateAuthCache, $injector, $q) {
  48. return {
  49. 'request': function (config) {
  50. var token = luticateAuthCache.getToken();
  51. if (token != null)
  52. config.headers['X-Authorization'] = token;
  53. return config;
  54. },
  55. 'responseError': function(rejection) {
  56. /*if (rejection.status == 401) {
  57. luticateAuthCache.removeUser();
  58. $injector.get('$state').transitionTo('login');
  59. }*/
  60. return $q.reject(rejection);
  61. }
  62. };
  63. }]);
  64. }])
  65. .run(['$rootScope', '$state', 'luticateAuthUsers',function ($rootScope, $state, luticateAuthUsers) {
  66. luticateAuthUsers.loadPermissions(null);
  67. $rootScope.$on('$stateChangeError', function (e, curr, prev) {
  68. $state.go('login');
  69. });
  70. }]);