30 lines
744 B
JavaScript
Executable file
30 lines
744 B
JavaScript
Executable file
'use strict';
|
|
|
|
// Config HTTP Error Handling
|
|
angular.module('users').config(['$httpProvider', '$state', 'Principal', '$q',
|
|
function($httpProvider, $state, Principal, $q) {
|
|
// 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);
|
|
|
|
// Redirect to signin page
|
|
$state.go('signin');
|
|
break;
|
|
case 403:
|
|
// Add unauthorized behaviour
|
|
break;
|
|
}
|
|
|
|
return $q.reject(rejection);
|
|
}
|
|
};
|
|
}
|
|
]);
|
|
}
|
|
]); |