-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.js
More file actions
42 lines (34 loc) · 1.39 KB
/
config.js
File metadata and controls
42 lines (34 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(function () {
'use strict';
angular.module('AngularApp').config(['$stateProvider', '$urlRouterProvider', config]);
function config($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider.state('main', {
url: '',
views: {
header: {
templateUrl: 'app/modules/common/views/header.html',
controller: 'HeaderController'
},
'navigation@main': {
templateUrl: 'app/modules/common/views/leftNavigation.html',
controller: 'MenuController'
}
}
});
}
angular.module('AngularApp').run(['$rootScope', 'AuthService', '$state', function ($rootScope, AuthService, $state) {
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
if (toState.data && toState.data.isAuthRequired) {
if (!AuthService.isAuthenticated()) {
event.preventDefault();
$state.go('login');
} else if (!AuthService.isAuthorized(toState.data.roles)) {
event.preventDefault();
$state.go('main.unauthorize');
}
}
}
);
}]);
})();