186 lines
4.4 KiB
HTML
186 lines
4.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Login</title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
|
<style>
|
|
* { border-radius: 0 !important; }
|
|
|
|
body {
|
|
font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
|
|
background: #fff;
|
|
color: #000;
|
|
padding: 20px;
|
|
}
|
|
|
|
.box {
|
|
border: 3px solid #000;
|
|
background: #fff;
|
|
}
|
|
|
|
input {
|
|
border: 2px solid #000;
|
|
padding: 8px;
|
|
font-size: 13px;
|
|
width: 100%;
|
|
background: #fff;
|
|
font-weight: bold;
|
|
}
|
|
|
|
input:focus {
|
|
outline: none;
|
|
background: #ffff00;
|
|
}
|
|
|
|
/* Chunky button style */
|
|
button {
|
|
border: 2px solid #000;
|
|
background: #fff;
|
|
padding: 6px 12px;
|
|
cursor: pointer;
|
|
font-size: 12px;
|
|
font-weight: 900;
|
|
text-transform: uppercase;
|
|
box-shadow: 3px 3px 0px #000;
|
|
}
|
|
|
|
button:hover {
|
|
background: #000;
|
|
color: #fff;
|
|
box-shadow: none;
|
|
transform: translate(2px, 2px);
|
|
}
|
|
|
|
button:active {
|
|
background: #ff0000;
|
|
color: #fff;
|
|
}
|
|
|
|
.nav-link {
|
|
font-weight: 900;
|
|
text-decoration: underline;
|
|
text-transform: uppercase;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.nav-link:hover {
|
|
background: #000;
|
|
color: #fff;
|
|
}
|
|
|
|
.label {
|
|
font-size: 10px;
|
|
font-weight: 900;
|
|
text-transform: uppercase;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.error {
|
|
border: 3px solid #000;
|
|
background: #ff0000;
|
|
color: #fff;
|
|
font-size: 11px;
|
|
padding: 6px;
|
|
margin-bottom: 12px;
|
|
font-weight: 900;
|
|
text-transform: uppercase;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="max-w-md mx-auto">
|
|
|
|
<header class="mb-8 border-b-8 border-black pb-4 flex justify-between items-start">
|
|
<h1 class="text-4xl font-black uppercase tracking-tighter leading-none">
|
|
System_Access
|
|
</h1>
|
|
|
|
<a href="/" class="nav-link">
|
|
← Back
|
|
</a>
|
|
</header>
|
|
|
|
<div class="box p-6">
|
|
|
|
{{if .Error}}
|
|
<div class="error">
|
|
ACCESS_DENIED
|
|
</div>
|
|
{{end}}
|
|
|
|
<form id="login-form" class="space-y-4">
|
|
|
|
<div>
|
|
<div class="label">Username</div>
|
|
<input id="username" required autocomplete="username">
|
|
</div>
|
|
|
|
<div>
|
|
<div class="label">Password</div>
|
|
<input id="password" type="password" required autocomplete="current-password">
|
|
</div>
|
|
|
|
<div class="pt-2">
|
|
<button type="submit">
|
|
Authenticate
|
|
</button>
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const form = document.getElementById("login-form");
|
|
|
|
form.addEventListener("submit", async (e) => {
|
|
e.preventDefault();
|
|
|
|
const username = document.getElementById("username").value;
|
|
const password = document.getElementById("password").value;
|
|
|
|
try {
|
|
const res = await fetch("/api/auth/login", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({
|
|
username: username,
|
|
password: password
|
|
})
|
|
});
|
|
|
|
const data = await res.json();
|
|
|
|
if (!res.ok) {
|
|
showError();
|
|
return;
|
|
}
|
|
|
|
window.location.href = "/admin";
|
|
|
|
} catch (err) {
|
|
showError();
|
|
}
|
|
});
|
|
|
|
function showError() {
|
|
let err = document.getElementById("error-box");
|
|
if (!err) {
|
|
err = document.createElement("div");
|
|
err.id = "error-box";
|
|
err.className = "error";
|
|
err.innerText = "ACCESS_DENIED";
|
|
form.prepend(err);
|
|
}
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html> |