diff options
-rw-r--r-- | modern/src/LoginPage.js | 2 | ||||
-rw-r--r-- | modern/src/MainPage.js | 3 | ||||
-rw-r--r-- | modern/src/MainToolbar.js | 1 | ||||
-rw-r--r-- | modern/src/SocketController.js | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/modern/src/LoginPage.js b/modern/src/LoginPage.js index 1da33663..99ff95b6 100644 --- a/modern/src/LoginPage.js +++ b/modern/src/LoginPage.js @@ -44,8 +44,6 @@ const useStyles = makeStyles(theme => ({ })); const LoginPage = () => { - const [filled, setFilled] = useState(false); - const [loading, setLoading] = useState(false); const [failed, setFailed] = useState(false); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); diff --git a/modern/src/MainPage.js b/modern/src/MainPage.js index c70e8169..f81d5e74 100644 --- a/modern/src/MainPage.js +++ b/modern/src/MainPage.js @@ -40,13 +40,14 @@ const useStyles = makeStyles(theme => ({ })); const MainPage = ({ width }) => { - const [loading, setLoading] = useState(true); + const [loading, setLoading] = useState(!document.authenticated); const classes = useStyles(); const history = useHistory(); useEffect(() => { fetch('/api/session').then(response => { if (response.ok) { + document.authenticated = true; setLoading(false); } else { history.push('/login'); diff --git a/modern/src/MainToolbar.js b/modern/src/MainToolbar.js index bf4aa402..038ab30a 100644 --- a/modern/src/MainToolbar.js +++ b/modern/src/MainToolbar.js @@ -46,6 +46,7 @@ const MainToolbar = () => { const handleLogout = () => { fetch('/api/session', { method: 'DELETE' }).then(response => { if (response.ok) { + document.authenticated = false; history.push('/login'); } }) diff --git a/modern/src/SocketController.js b/modern/src/SocketController.js index 6de3369a..d693c43d 100644 --- a/modern/src/SocketController.js +++ b/modern/src/SocketController.js @@ -54,7 +54,7 @@ const SocketController = (props) => { } connectSocket(); }); - }, []); + }, [dispatch, connectSocket]); return null; } |