tellform/public/modules/users/config/users.client.config.js
2016-05-16 15:26:10 -07:00

28 lines
932 B
JavaScript
Executable file

'use strict';
// Config HTTP Error Handling
angular.module('users').config(['$httpProvider',
function($httpProvider) {
$httpProvider.interceptors.push(function($q, $location) {
return {
responseError: function(response) {
if( $location.path() !== '/users/me' && response.config){
if(response.config.url !== '/users/me'){
console.log('intercepted rejection of ', response.config.url, response.status);
if (response.status === 401) {
console.log($location.path());
// 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');
}
}
}
return $q.reject(response);
}
};
});
}]);