getting token in auth wrapper and redirecting if it's no longer valid
This commit is contained in:
parent
c2bfdd99aa
commit
d8151f618a
3 changed files with 44 additions and 29 deletions
|
|
@ -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>
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue