From 67c27ff614d613c9e317ba8d4717dc0530783db6 Mon Sep 17 00:00:00 2001 From: NlightN22 Date: Fri, 1 Mar 2024 19:27:44 +0700 Subject: [PATCH] fix auth redirect --- src/App.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index ba8cb3d..3d2f48b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -11,7 +11,6 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import RetryErrorPage from './pages/RetryErrorPage'; import { keycloakConfig } from '.'; - const queryClient = new QueryClient({ defaultOptions: { queries: { @@ -21,7 +20,7 @@ const queryClient = new QueryClient({ }) function App() { - const maxErrorAuthConts = 10 + const maxErrorAuthConts = 2 const systemColorScheme = useColorScheme() const [colorScheme, setColorScheme] = useState(getCookie('mantine-color-scheme') as ColorScheme || systemColorScheme) const [authErrorCounter, setAuthErrorCounter] = useState(0) @@ -37,7 +36,8 @@ function App() { useEffect(() => { if (!hasAuthParams() && !auth.isAuthenticated && !auth.activeNavigator && !auth.isLoading && authErrorCounter < maxErrorAuthConts) { - console.log('not authenticated! redirect!') + console.log('Not authenticated! Redirect! ErrorCounter', authErrorCounter) + setAuthErrorCounter(prevCount => prevCount + 1) auth.signinRedirect() } }, [auth, auth.isAuthenticated, auth.activeNavigator, auth.isLoading, auth.signinRedirect]) @@ -55,13 +55,13 @@ function App() { } if (!auth.isAuthenticated && !auth.isLoading && authErrorCounter < maxErrorAuthConts) { - console.log('not authenticated! redirect!') + console.log('Not authenticated! Redirect! auth ErrorCounter', authErrorCounter) setAuthErrorCounter(prevCount => prevCount + 1); auth.signinRedirect() } if ((!hasAuthParams() && !auth.isAuthenticated && !auth.isLoading) || auth.error) { - setAuthErrorCounter(prevCount => prevCount + 1); + setAuthErrorCounter(prevCount => prevCount + 1) console.error(`auth.error:`, auth.error) return }