Confirm user's token on navigation, clear user cache properly

This commit is contained in:
Tanner Collin 2020-02-04 08:32:01 +00:00
parent 26845a5921
commit 3565bddf8d

View File

@ -40,14 +40,14 @@ function App() {
})
.catch(err => {
console.log(err);
setUser(false);
setUserCache(null);
});
}, [token, refreshCount]);
function logout() {
if (yousure) {
setTokenCache('');
setUserCache(false);
setUserCache(null);
setYousure(false);
history.push('/');
window.scrollTo(0, 0);
@ -56,6 +56,18 @@ function App() {
}
}
useEffect(() => {
user && requester('/ping/', 'POST', token, {})
.then()
.catch(err => {
console.log(err);
if (err.data && err.data.detail === 'Invalid token.') {
logout(); // You Sure?
logout();
}
});
}, [history.location]);
return (
<div>
<div className='content-wrap'>