mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 04:15:43 +00:00
fixes
This commit is contained in:
@@ -26,11 +26,14 @@ function getCookie(name: string): string | undefined {
|
|||||||
|
|
||||||
const useAuth = () => {
|
const useAuth = () => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const hasToken = !!getCookie("auth-token");
|
||||||
|
|
||||||
const authQuery = useQuery(
|
const authQuery = useQuery(
|
||||||
api.auth.getMyInfo.queryOptions({
|
api.auth.getMyInfo.queryOptions({
|
||||||
|
enabled: hasToken,
|
||||||
retry: false,
|
retry: false,
|
||||||
staleTime: 10 * 60 * 1000,
|
staleTime: 10 * 60 * 1000,
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -51,9 +54,13 @@ const useAuth = () => {
|
|||||||
isUserPending: authQuery.isPending,
|
isUserPending: authQuery.isPending,
|
||||||
isCompanyPending: companyQuery.isPending,
|
isCompanyPending: companyQuery.isPending,
|
||||||
});
|
});
|
||||||
}, [authQuery, companyQuery]);
|
}, [
|
||||||
|
authQuery.data,
|
||||||
|
companyQuery.data,
|
||||||
|
authQuery.isPending,
|
||||||
|
companyQuery.isPending,
|
||||||
|
]);
|
||||||
|
|
||||||
const hasToken = !!getCookie("auth-token");
|
|
||||||
const isPending = authQuery.isPending && hasToken;
|
const isPending = authQuery.isPending && hasToken;
|
||||||
|
|
||||||
const login = async (
|
const login = async (
|
||||||
|
|||||||
@@ -113,9 +113,6 @@ client.interceptors.response.use(
|
|||||||
} catch (refreshError) {
|
} catch (refreshError) {
|
||||||
processQueue(refreshError, undefined);
|
processQueue(refreshError, undefined);
|
||||||
clearAuthCookies();
|
clearAuthCookies();
|
||||||
if (window.location.pathname !== "/login") {
|
|
||||||
window.location.href = "/login";
|
|
||||||
}
|
|
||||||
return Promise.reject(refreshError);
|
return Promise.reject(refreshError);
|
||||||
} finally {
|
} finally {
|
||||||
isRefreshing = false;
|
isRefreshing = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user