getting token in auth wrapper and redirecting if it's no longer valid

This commit is contained in:
Carter 2024-10-25 15:16:02 -06:00
parent c2bfdd99aa
commit d8151f618a
3 changed files with 44 additions and 29 deletions

View file

@ -6,7 +6,7 @@ import App from './App'
import { useState } from 'react'
function AuthHTTPWrapper() {
const [gotToken, setGotToken] = useState(false)
const [token, setToken] = useState<string | undefined>(undefined)
let url: string | undefined = window.location.origin;
let audience: string | undefined;
@ -31,14 +31,14 @@ function AuthHTTPWrapper() {
useRefreshTokens={true}
cacheLocation='localstorage'
>
<AuthWrapper>
<HTTPProvider setGotToken={setGotToken}>
{gotToken ?
<AuthWrapper setToken={setToken}>
{ token ?
<HTTPProvider token={token}>
<App/>
:
<p>hi</p>
}
</HTTPProvider>
</HTTPProvider>
:
<p>no token</p>
}
</AuthWrapper>
</Auth0Provider>
)