Skip to content

Commit 7531d8a

Browse files
committed
fixed http interceptor using un-minsafe format
Really annoying trying to figure out why the production build was throwing unknown provider errors!
1 parent ef69336 commit 7531d8a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Diff for: templates/javascript/app.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict';
22

33
angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
4-
.config(function ($routeProvider, $locationProvider<% if (mongo && mongoPassportUser) { %>, $httpProvider<% } %>) {
4+
.config(function ($routeProvider, $locationProvider<% if (mongoPassportUser) { %>, $httpProvider<% } %>) {
55
$routeProvider
66
.when('/', {
77
templateUrl: 'partials/main',
88
controller: 'MainCtrl'
9-
})<% if (mongo && mongoPassportUser) { %>
9+
})<% if (mongoPassportUser) { %>
1010
.when('/login', {
1111
templateUrl: 'partials/login',
1212
controller: 'LoginCtrl'
@@ -23,9 +23,10 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) {
2323
.otherwise({
2424
redirectTo: '/'
2525
});
26-
$locationProvider.html5Mode(true);<% if (mongo && mongoPassportUser) { %>
26+
$locationProvider.html5Mode(true);<% if (mongoPassportUser) { %>
27+
2728
// Intercept 401s and 403s and redirect you to login
28-
var unauthorized = function($q, $location) {
29+
$httpProvider.interceptors.push(['$q', '$location', function($q, $location) {
2930
return {
3031
'responseError': function(response) {
3132
if(response.status === 401 || response.status === 403) {
@@ -37,9 +38,7 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) {
3738
}
3839
}
3940
};
40-
};
41-
42-
$httpProvider.interceptors.push(unauthorized);
41+
}]);
4342
})
4443
.run(function ($rootScope, $location, Auth) {
4544

0 commit comments

Comments
 (0)