aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modern/src/LoginPage.js2
-rw-r--r--modern/src/MainPage.js3
-rw-r--r--modern/src/MainToolbar.js1
-rw-r--r--modern/src/SocketController.js2
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;
}