Implement login

This commit is contained in:
Kai Vogelgesang
2020-04-17 03:10:52 +02:00
parent f966ee4abc
commit 4886f78357
2 changed files with 13 additions and 23 deletions

View File

@@ -10,22 +10,16 @@
<body>
this is the base site
<a href="/newclient">Log in</a>
<br>
<input id="some_input" type="text" placeholder="dunno"/>
<button id="btn_dunno">idk</button>
<input id="username" type="text" placeholder="Joe"/>
<button id="btn_register">idk</button>
<script>
document.getElementById("btn_dunno").onclick = async function (e) {
let text = document.getElementById("some_input").value;
let data = {"username": text};
document.getElementById("btn_register").onclick = function (e) {
let username = document.getElementById("username").value;
await fetch('/newclient', {
method: 'POST',
body: JSON.stringify(data),
})
window.location.replace(`/register/${encodeURIComponent(username)}`)
};
</script>
</body>