diff options
author | LarsVomMars | 2020-07-30 20:16:54 +0200 |
---|---|---|
committer | LarsVomMars | 2020-07-30 20:16:54 +0200 |
commit | f02c4054984fb8c12bfa4af9560a5b2be38810c0 (patch) | |
tree | d4519a92b739640e061847831d221e3e2488a83c /src/public | |
parent | 86c68c3648c94ca9f66f3eb408973368bed28681 (diff) |
Added views and server setup
Diffstat (limited to 'src/public')
-rw-r--r-- | src/public/js/login.js | 18 | ||||
-rw-r--r-- | src/public/js/setup.js | 21 |
2 files changed, 39 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 diff --git a/src/public/js/setup.js b/src/public/js/setup.js new file mode 100644 index 0000000..ef31e18 --- /dev/null +++ b/src/public/js/setup.js @@ -0,0 +1,21 @@ +const form = document.getElementById("setup-form"); + +form.addEventListener('submit', async e => { + e.preventDefault(); + const username = document.getElementById('username').value; + const email = document.getElementById('email').value; + const password = document.getElementById('password').value; + const admin = true; + + const body = JSON.stringify({username, email, password, admin}); + + const resp = await fetch("/user/register", { + method: "POST", + headers: {'Content-Type': 'application/json'}, + body, + }) + const res = await resp.json(); + if (res.success) location.replace("/user/login"); + else alert("ASJHDOAISJDLKAJSD"); + +})
\ No newline at end of file |