fix auth redirect
This commit is contained in:
parent
19640f8ece
commit
67c27ff614
10
src/App.tsx
10
src/App.tsx
@ -11,7 +11,6 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|||||||
import RetryErrorPage from './pages/RetryErrorPage';
|
import RetryErrorPage from './pages/RetryErrorPage';
|
||||||
import { keycloakConfig } from '.';
|
import { keycloakConfig } from '.';
|
||||||
|
|
||||||
|
|
||||||
const queryClient = new QueryClient({
|
const queryClient = new QueryClient({
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
queries: {
|
queries: {
|
||||||
@ -21,7 +20,7 @@ const queryClient = new QueryClient({
|
|||||||
})
|
})
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const maxErrorAuthConts = 10
|
const maxErrorAuthConts = 2
|
||||||
const systemColorScheme = useColorScheme()
|
const systemColorScheme = useColorScheme()
|
||||||
const [colorScheme, setColorScheme] = useState<ColorScheme>(getCookie('mantine-color-scheme') as ColorScheme || systemColorScheme)
|
const [colorScheme, setColorScheme] = useState<ColorScheme>(getCookie('mantine-color-scheme') as ColorScheme || systemColorScheme)
|
||||||
const [authErrorCounter, setAuthErrorCounter] = useState(0)
|
const [authErrorCounter, setAuthErrorCounter] = useState(0)
|
||||||
@ -37,7 +36,8 @@ function App() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!hasAuthParams() &&
|
if (!hasAuthParams() &&
|
||||||
!auth.isAuthenticated && !auth.activeNavigator && !auth.isLoading && authErrorCounter < maxErrorAuthConts) {
|
!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.signinRedirect()
|
||||||
}
|
}
|
||||||
}, [auth, auth.isAuthenticated, auth.activeNavigator, auth.isLoading, auth.signinRedirect])
|
}, [auth, auth.isAuthenticated, auth.activeNavigator, auth.isLoading, auth.signinRedirect])
|
||||||
@ -55,13 +55,13 @@ function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!auth.isAuthenticated && !auth.isLoading && authErrorCounter < maxErrorAuthConts) {
|
if (!auth.isAuthenticated && !auth.isLoading && authErrorCounter < maxErrorAuthConts) {
|
||||||
console.log('not authenticated! redirect!')
|
console.log('Not authenticated! Redirect! auth ErrorCounter', authErrorCounter)
|
||||||
setAuthErrorCounter(prevCount => prevCount + 1);
|
setAuthErrorCounter(prevCount => prevCount + 1);
|
||||||
auth.signinRedirect()
|
auth.signinRedirect()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!hasAuthParams() && !auth.isAuthenticated && !auth.isLoading) || auth.error) {
|
if ((!hasAuthParams() && !auth.isAuthenticated && !auth.isLoading) || auth.error) {
|
||||||
setAuthErrorCounter(prevCount => prevCount + 1);
|
setAuthErrorCounter(prevCount => prevCount + 1)
|
||||||
console.error(`auth.error:`, auth.error)
|
console.error(`auth.error:`, auth.error)
|
||||||
return <Forbidden />
|
return <Forbidden />
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user