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

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