This repository has been archived on 2024-10-30. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
swb6-it-sec/Lab01/app/templates/register.tmpl

44 lines
1.5 KiB
Cheetah

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ .title }}</title>
{{template "head" .}}
</head>
<body>
{{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>
{{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);
fetch("/register", {method: 'POST', body: formData, redirect: 'follow'})
.then(response => response.json())
.then(() => {
window.location.href = "/";
}
).catch(error => console.log(error));
}
</script>
</body>
</html>