aboutsummaryrefslogtreecommitdiff
path: root/modern/src/LoginPage.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/LoginPage.js')
-rw-r--r--modern/src/LoginPage.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/modern/src/LoginPage.js b/modern/src/LoginPage.js
index 429a6e6f..2636c807 100644
--- a/modern/src/LoginPage.js
+++ b/modern/src/LoginPage.js
@@ -63,17 +63,17 @@ const LoginPage = () => {
// TODO: Implement registration
}
- const handleLogin = (event) => {
+ const handleLogin = async (event) => {
event.preventDefault();
- fetch('/api/session', { method: 'POST', body: new URLSearchParams(`email=${email}&password=${password}`) }).then(response => {
- if (response.ok) {
- dispatch(sessionActions.authenticated(true));
- history.push('/');
- } else {
- setFailed(true);
- setPassword('');
- }
- });
+ const response = await fetch('/api/session', { method: 'POST', body: new URLSearchParams(`email=${email}&password=${password}`) });
+ if (response.ok) {
+ const user = await response.json();
+ dispatch(sessionActions.updateUser(user));
+ history.push('/');
+ } else {
+ setFailed(true);
+ setPassword('');
+ }
}
return (