tellform/public/modules/users/config/users.client.config.js

28 lines
932 B
JavaScript
Raw Normal View History

2015-06-30 06:12:32 +00:00
'use strict';
2015-06-29 22:51:29 +00:00
2015-06-30 06:12:32 +00:00
// Config HTTP Error Handling
2015-06-30 17:36:51 +00:00
angular.module('users').config(['$httpProvider',
function($httpProvider) {
2015-06-30 19:42:02 +00:00
$httpProvider.interceptors.push(function($q, $location) {
return {
responseError: function(response) {
2015-11-03 21:01:07 +00:00
if( $location.path() !== '/users/me' && response.config){
if(response.config.url !== '/users/me'){
2015-08-06 05:52:59 +00:00
console.log('intercepted rejection of ', response.config.url, response.status);
if (response.status === 401) {
2016-05-16 22:26:10 +00:00
console.log($location.path());
2015-08-06 05:52:59 +00:00
// save the current location so that login can redirect back
$location.nextAfterLogin = $location.path();
$location.path('/signin');
}else if(response.status === 403){
$location.path('/access_denied');
}
2015-07-01 23:14:39 +00:00
}
2015-06-30 19:42:02 +00:00
}
return $q.reject(response);
}
};
});
2016-05-16 22:26:10 +00:00
}]);