56 lines
1.5 KiB
HTML
56 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Login</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="icon" href="data:,">
|
|
<style>
|
|
html {
|
|
font-family: sans-serif;
|
|
color: white;
|
|
background: seagreen linear-gradient(315deg, rgba(255,255,255,0.2), transparent);
|
|
height: 100%;
|
|
}
|
|
div {
|
|
margin: 1em;
|
|
}
|
|
#error {
|
|
color: red;
|
|
}
|
|
</style>
|
|
<script>
|
|
function error(msg) {
|
|
document.querySelector("#error").textContent = msg
|
|
}
|
|
|
|
async function login(evt) {
|
|
evt.preventDefault()
|
|
let req = await fetch(evt.target.action, {
|
|
method: evt.target.method,
|
|
body: new FormData(evt.target),
|
|
credentials: "same-origin",
|
|
})
|
|
if (! req.ok) {
|
|
error(req.statusText || "Authentication failed")
|
|
return
|
|
}
|
|
location.reload(true)
|
|
}
|
|
function init() {
|
|
document.querySelector("form").addEventListener("submit", login)
|
|
}
|
|
|
|
window.addEventListener("load", init)
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h1>Log In</h1>
|
|
<form action="/" method="post">
|
|
<div>Username: <input type="text" autocomplete="username" name="username"></div>
|
|
<div>Password: <input type="password" autocomplete="current-password" name="password"></div>
|
|
<div><input type="submit" value="Log In"></div>
|
|
</form>
|
|
<div id="error"></div>
|
|
</body>
|
|
</html>
|