2015-06-30 16:15:16 +00:00
|
|
|
'use strict';
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-06-30 11:05:44 +00:00
|
|
|
// Config HTTP Error Handling
|
2015-06-30 17:36:51 +00:00
|
|
|
angular.module('users').config(['$httpProvider',
|
|
|
|
function($httpProvider) {
|
|
|
|
// Set the httpProvider "not authorized" interceptor
|
|
|
|
$httpProvider.interceptors.push(['$q', '$state', 'Principal',
|
|
|
|
function($q, $state, Principal) {
|
|
|
|
return {
|
|
|
|
responseError: function(rejection) {
|
|
|
|
switch (rejection.status) {
|
|
|
|
case 401:
|
|
|
|
// Deauthenticate the global user
|
|
|
|
Principal.authenticate(null);
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-06-30 17:36:51 +00:00
|
|
|
// Redirect to signin page
|
|
|
|
$state.go('signin');
|
|
|
|
break;
|
|
|
|
case 403:
|
|
|
|
// Add unauthorized behaviour
|
|
|
|
break;
|
|
|
|
}
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-06-30 17:36:51 +00:00
|
|
|
return $q.reject(rejection);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
]);
|