aboutsummaryrefslogtreecommitdiff
path: root/src/public/js/login.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/public/js/login.js')
-rw-r--r--src/public/js/login.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/public/js/login.js b/src/public/js/login.js
new file mode 100644
index 0000000..681b02f
--- /dev/null
+++ b/src/public/js/login.js
@@ -0,0 +1,18 @@
+const form = document.getElementById("login-form");
+
+form.addEventListener('submit', async e => {
+ e.preventDefault();
+ const username = document.getElementById("username").value;
+ const password = document.getElementById("password").value;
+
+ const body = JSON.stringify({username, password});
+
+ const resp = await fetch("/user/login", {
+ method: "POST",
+ headers: {'Content-Type': 'application/json'},
+ body,
+ });
+ const res = await resp.json();
+ if (res.success) location.replace("/");
+ else alert("ASJHDOAISJDLKAJSD");
+}) \ No newline at end of file