1
1
'use strict' ;
2
2
3
3
angular . module ( '<%= scriptAppName %>' , [ < %= angularModules % > ])< % if ( ngRoute ) { % >
4
- . config ( function ( $routeProvider , $locationProvider < % if ( mongo && mongoPassportUser ) { % > , $httpProvider < % } % > ) {
4
+ . config ( function ( $routeProvider , $locationProvider < % if ( mongoPassportUser ) { % > , $httpProvider < % } % > ) {
5
5
$routeProvider
6
6
. when ( '/' , {
7
7
templateUrl : 'partials/main' ,
8
8
controller : 'MainCtrl'
9
- } ) < % if ( mongo && mongoPassportUser ) { % >
9
+ } ) < % if ( mongoPassportUser ) { % >
10
10
. when ( '/login' , {
11
11
templateUrl : 'partials/login' ,
12
12
controller : 'LoginCtrl'
@@ -23,9 +23,10 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) {
23
23
. otherwise ( {
24
24
redirectTo : '/'
25
25
} ) ;
26
- $locationProvider . html5Mode ( true ) ; < % if ( mongo && mongoPassportUser ) { % >
26
+ $locationProvider . html5Mode ( true ) ; < % if ( mongoPassportUser ) { % >
27
+
27
28
// Intercept 401s and 403s and redirect you to login
28
- var unauthorized = function ( $q , $location ) {
29
+ $httpProvider . interceptors . push ( [ '$q' , '$location' , function ( $q , $location ) {
29
30
return {
30
31
'responseError' : function ( response ) {
31
32
if ( response . status === 401 || response . status === 403 ) {
@@ -37,9 +38,7 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) {
37
38
}
38
39
}
39
40
} ;
40
- } ;
41
-
42
- $httpProvider . interceptors . push ( unauthorized ) ;
41
+ } ] ) ;
43
42
} )
44
43
. run ( function ( $rootScope , $location , Auth ) {
45
44
0 commit comments