fix register and login handler for future edits
This commit is contained in:
parent
b5f1ccf98d
commit
177a26a2e9
6 changed files with 97 additions and 43 deletions
|
@ -9,29 +9,16 @@
|
|||
{{template "navbar" .}}
|
||||
|
||||
<div class="position-absolute top-50 start-50 translate-middle">
|
||||
<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 onclick="registerUser()" class="btn btn-primary">Submit</button>
|
||||
<div class="fs-3">{{ .title }}</div>
|
||||
<hr>
|
||||
{{template "userForm" .}}
|
||||
<a class="link-secondary" href="/login">Login instead</a>
|
||||
</div>
|
||||
|
||||
|
||||
{{template "scripts" .}}
|
||||
<script>
|
||||
function registerUser() {
|
||||
const username = document.getElementById("username").value;
|
||||
const password = document.getElementById("password").value;
|
||||
let formData = new FormData();
|
||||
formData.append("username", username);
|
||||
formData.append("password", password);
|
||||
|
||||
function submitForm(formData) {
|
||||
fetch("/register", {method: 'POST', body: formData, redirect: 'follow'})
|
||||
.then(response => response.json())
|
||||
.then(() => {
|
||||
|
|
Reference in a new issue