really basic login

This commit is contained in:
Florian Hoss 2022-04-04 10:16:29 +02:00
parent 177a26a2e9
commit 539a36dffe
6 changed files with 116 additions and 50 deletions

View file

@ -18,13 +18,15 @@
{{template "scripts" .}}
<script>
function submitForm(formData) {
fetch("/register", {method: 'POST', body: formData, redirect: 'follow'})
.then(response => response.json())
.then(() => {
window.location.href = "/";
}
).catch(error => console.log(error));
async function submitForm(formData) {
const response = await fetch("/register", {method: 'POST', body: formData, redirect: 'follow'});
if (response.ok) {
const json = await response.json();
console.log("JSON:", json.message);
redirect("/");
} else {
redirect("/register");
}
}
</script>
</body>