fix register and login handler for future edits

This commit is contained in:
Florian Hoss 2022-04-04 09:15:02 +02:00
parent b5f1ccf98d
commit 177a26a2e9
6 changed files with 97 additions and 43 deletions

View file

@ -9,21 +9,22 @@
{{template "navbar" .}}
<div class="position-absolute top-50 start-50 translate-middle">
<form action="http://localhost:8080/register" method="POST">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" aria-describedby="emailHelp">
<div id="emailHelp" class="form-text">The username needs to be unique</div>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" aria-describedby="passwordHelp">
<div id="passwordHelp" class="form-text">The password needs to be different from the username</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<div class="fs-3">{{ .title }}</div>
<hr>
{{template "userForm" .}}
<a class="link-secondary" href="/register">Register instead</a>
</div>
{{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));
}
</script>
</body>
</html>