1
0
Fork 0

chore(org): Updates for github data and account refresh

This commit is contained in:
Joost De Cock 2023-08-17 17:05:08 +02:00
parent b3a21ad955
commit cf26ba933a
7 changed files with 172 additions and 66 deletions

View file

@ -104,7 +104,7 @@ const ConsentLacking = ({ t, banner }) => (
export const AuthWrapper = ({ children, app, requiredRole = 'user' }) => {
const { t } = useTranslation(ns)
const { account, token, admin, stopImpersonating } = useAccount()
const { account, token, admin, stopImpersonating, signOut } = useAccount()
const backend = useBackend()
const [ready, setReady] = useState(false)
@ -123,9 +123,15 @@ export const AuthWrapper = ({ children, app, requiredRole = 'user' }) => {
})
}
}
const verifyUser = async () => {
const result = await backend.ping()
if (result.success) {
} else signOut()
}
if (admin && admin.token) verifyAdmin()
if (token) verifyUser()
setReady(true)
}, [admin])
}, [admin, token])
if (!ready) return <Loading />