fix merge

This commit is contained in:
Patryk
2025-06-09 21:49:07 +02:00
parent a51345fd93
commit a04ef906cd
6 changed files with 246 additions and 351 deletions

View File

@@ -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,