66 lines
2.4 KiB
HTML
66 lines
2.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>Linear Void Admin Login</title>
|
|
<link rel="stylesheet" href="../../src/style.css" />
|
|
</head>
|
|
|
|
<body class="auth-body">
|
|
<main class="auth-shell" aria-label="Admin authentication">
|
|
<section class="auth-card" aria-labelledby="auth-title">
|
|
<p class="auth-kicker">Linear Void</p>
|
|
<h1 id="auth-title">Admin Login</h1>
|
|
<p class="auth-subtitle">Authenticate to access protected admin controls.</p>
|
|
|
|
<form id="login-form" class="form-stack" novalidate>
|
|
<label for="username">Username</label>
|
|
<input id="username" type="text" class="text-input" autocomplete="username" required />
|
|
|
|
<label for="password">Password</label>
|
|
<input id="password" type="password" class="text-input" autocomplete="current-password" required />
|
|
|
|
<button id="submit" type="submit" class="btn btn-primary btn-block">Sign in</button>
|
|
<p id="status" class="status-line" aria-live="polite"></p>
|
|
</form>
|
|
</section>
|
|
</main>
|
|
|
|
<script>
|
|
const form = document.getElementById("login-form");
|
|
const username = document.getElementById("username");
|
|
const password = document.getElementById("password");
|
|
const submit = document.getElementById("submit");
|
|
const status = document.getElementById("status");
|
|
|
|
form.addEventListener("submit", async (event) => {
|
|
event.preventDefault();
|
|
submit.disabled = true;
|
|
status.textContent = "Signing in...";
|
|
status.className = "status-line";
|
|
|
|
try {
|
|
const response = await fetch("/api/admin/login", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ username: username.value, password: password.value }),
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP ${response.status}`);
|
|
}
|
|
|
|
window.location.href = "/admin/";
|
|
} catch (error) {
|
|
console.error("Failed to sign in", error);
|
|
status.textContent = "Login failed. Check your credentials.";
|
|
status.className = "status-line status-error";
|
|
} finally {
|
|
submit.disabled = false;
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|