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/login.tmpl

35 lines
921 B
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="fs-3">{{ .title }}</div>
<hr>
{{template "userForm" .}}
<a class="link-secondary" href="/view/register">Register instead</a>
</div>
{{template "scripts" .}}
{{template "formScripts" .}}
<script>
userLoggedIn().then((loggedIn) => loggedIn && redirect("/"));
async function submitForm(formData) {
const response = await fetch("/auth/login", {method: 'POST', body: formData, redirect: 'follow'});
if (response.ok) {
const json = await response.json();
setCookie("username", json.username, 1);
redirect("/");
} else {
redirect("/view/login");
}
}
</script>
</body>
</html>