mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
refactoring: authentication with react-query.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import axios from 'axios';
|
||||
import { store } from 'store/createStore';
|
||||
import { logout } from 'store/authentication/authentication.actions';
|
||||
import { setGlobalErrors } from 'store/globalErrors/globalErrors.actions';
|
||||
const http = axios.create();
|
||||
|
||||
|
||||
@@ -27,13 +25,13 @@ http.interceptors.request.use((request) => {
|
||||
http.interceptors.response.use((response) => response, (error) => {
|
||||
const { status } = error.response;
|
||||
|
||||
if (status >= 500) {
|
||||
store.dispatch(setGlobalErrors({ something_wrong: true }));
|
||||
}
|
||||
if (status === 401) {
|
||||
store.dispatch(setGlobalErrors({ session_expired: true }));
|
||||
store.dispatch(logout());
|
||||
}
|
||||
// if (status >= 500) {
|
||||
// store.dispatch(setGlobalErrors({ something_wrong: true }));
|
||||
// }
|
||||
// if (status === 401) {
|
||||
// // store.dispatch(setGlobalErrors({ session_expired: true }));
|
||||
// // store.dispatch(logout());
|
||||
// }
|
||||
return Promise.reject(error);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user