mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 18:28:47 +00:00
Merge pull request #47 from ClaytonWWilson/block_topics
Fix login page loop bug
This commit is contained in:
commit
60f83da514
@ -36,14 +36,19 @@ const theme = createMuiTheme(themeObject);
|
|||||||
|
|
||||||
const token = localStorage.FBIdToken;
|
const token = localStorage.FBIdToken;
|
||||||
if (token) {
|
if (token) {
|
||||||
const decodedToken = jwtDecode(token);
|
try {
|
||||||
if (decodedToken.exp * 1000 < Date.now()) {
|
const decodedToken = jwtDecode(token);
|
||||||
store.dispatch(logoutUser);
|
if (decodedToken.exp * 1000 < Date.now()) {
|
||||||
|
store.dispatch(logoutUser());
|
||||||
|
window.location.href = "/login";
|
||||||
|
} else {
|
||||||
|
store.dispatch({ type: SET_AUTHENTICATED });
|
||||||
|
axios.defaults.headers.common['Authorization'] = token;
|
||||||
|
store.dispatch(getUserData());
|
||||||
|
}
|
||||||
|
} catch (invalidTokenError) {
|
||||||
|
store.dispatch(logoutUser());
|
||||||
window.location.href = "/login";
|
window.location.href = "/login";
|
||||||
} else {
|
|
||||||
store.dispatch({ type: SET_AUTHENTICATED });
|
|
||||||
axios.defaults.headers.common['Authorization'] = token;
|
|
||||||
store.dispatch(getUserData());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user