fix merge
This commit is contained in:
@@ -11,22 +11,23 @@ let interceptorInitialized = false;
|
||||
export const useAuthStore = create(
|
||||
persist(
|
||||
(set, get) => {
|
||||
// if (!interceptorInitialized.current) {
|
||||
// axios.interceptors.response.use(
|
||||
// (response) => response,
|
||||
// (error) => {
|
||||
// if (
|
||||
// (error.response && error.response.status === 401) ||
|
||||
// error.response.status === 403
|
||||
// ) {
|
||||
// set({ user_id: null, token: null, isLoading: false });
|
||||
// delete axios.defaults.headers.common["Authorization"];
|
||||
// }
|
||||
// return Promise.reject(error);
|
||||
// }
|
||||
// );
|
||||
// interceptorInitialized = true;
|
||||
// }
|
||||
if (!interceptorInitialized.current) {
|
||||
axios.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
if (
|
||||
(error.response && error.response.status === 401) ||
|
||||
error.response.status === 403
|
||||
) {
|
||||
set({ user_id: null, token: null, isLoading: false });
|
||||
delete axios.defaults.headers.common["Authorization"];
|
||||
router.replace("/login");
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
interceptorInitialized = true;
|
||||
}
|
||||
return {
|
||||
user_id: null,
|
||||
token: null,
|
||||
|
||||
Reference in New Issue
Block a user