Commit 69e56e4f authored by Evren Kutar's avatar Evren Kutar

interceptors in seperate file

parent 07e5cc53
......@@ -174,27 +174,4 @@ app.config(['$routeProvider', function ($routeProvider) {
}
}
});
}).config(['$httpProvider', function ($httpProvider) {
/**
* the interceptor for all requests to check response
* 4xx - 5xx errors will be handled here
*/
$httpProvider.interceptors.push(function ($q) {
return {
'response': function (response) {
//Will only be called for HTTP up to 300
return response;
},
'responseError': function (rejection) {
// if unauthorized then redirect to login page
if(rejection.status === 400) {
location.reload();
}
if(rejection.status === 401) {
location.path('#/login');
}
return $q.reject(rejection);
}
};
});
}]);
\ No newline at end of file
});
\ No newline at end of file
......@@ -84,6 +84,7 @@
<script type="text/javascript" src="bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"></script>
<script src="app.js"></script>
<script src="zetalib/interceptors.js"></script>
<script src="app_routes.js"></script>
<!--<script src="zlib/general.js"></script>-->
......
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
app.config(['$httpProvider', function ($httpProvider) {
/**
* the interceptor for all requests to check response
* 4xx - 5xx errors will be handled here
*/
$httpProvider.interceptors.push(function ($q) {
return {
'response': function (response) {
//Will only be called for HTTP up to 300
return response;
},
'responseError': function (rejection) {
// if unauthorized then redirect to login page
if(rejection.status === 400) {
location.reload();
}
if(rejection.status === 401) {
location.path('#/login');
}
return $q.reject(rejection);
}
};
});
}]);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment