chore: add condition for redirecting to SSO

This commit is contained in:
ValdiANS
2025-12-10 21:47:58 +07:00
parent 4356bd8803
commit 9628ee88ad
+5 -2
View File
@@ -37,13 +37,16 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
// Explicitly handle 401 redirect from the component level // Explicitly handle 401 redirect from the component level
useEffect(() => { useEffect(() => {
if (userErrorResponse?.response?.status === 401) { if (
isResponseError(userResponse) &&
userErrorResponse?.response?.status === 401
) {
// Clear cache to prevent stale data from rendering children // Clear cache to prevent stale data from rendering children
// mutate('/sso/userinfo', undefined, { revalidate: false }); // Optional: if using global mutate // mutate('/sso/userinfo', undefined, { revalidate: false }); // Optional: if using global mutate
setUser(undefined); setUser(undefined);
redirectToSSO(); redirectToSSO();
} }
}, [userErrorResponse, setUser]); }, [userErrorResponse, setUser, userResponse]);
useEffect(() => { useEffect(() => {
setIsLoadingUser(isLoadingUserResponse); setIsLoadingUser(isLoadingUserResponse);