mirror of
https://github.com/bitwarden/web
synced 2025-12-11 22:03:21 +00:00
reorganize project folder structure and remove asp.net dependency
This commit is contained in:
29
src/app/apiInterceptor.js
Normal file
29
src/app/apiInterceptor.js
Normal file
@@ -0,0 +1,29 @@
|
||||
angular
|
||||
.module('bit')
|
||||
|
||||
.factory('apiInterceptor', function ($injector, $q, toastr) {
|
||||
return {
|
||||
request: function (config) {
|
||||
return config;
|
||||
},
|
||||
response: function (response) {
|
||||
if (response.status === 401 || response.status === 403) {
|
||||
$injector.get('authService').logOut();
|
||||
$injector.get('$state').go('frontend.login.info').then(function () {
|
||||
toastr.warning('Your login session has expired.', 'Logged out');
|
||||
});
|
||||
}
|
||||
|
||||
return response || $q.when(response);
|
||||
},
|
||||
responseError: function (rejection) {
|
||||
if (rejection.status === 401 || rejection.status === 403) {
|
||||
$injector.get('authService').logOut();
|
||||
$injector.get('$state').go('frontend.login.info').then(function () {
|
||||
toastr.warning('Your login session has expired.', 'Logged out');
|
||||
});
|
||||
}
|
||||
return $q.reject(rejection);
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user