7f7868f7cf
---ci--- phase: 5 milestone: v0.1 status: complete requirements: covered: [REQ-01, REQ-02, REQ-03, REQ-04, REQ-05, REQ-06, REQ-07, REQ-08, REQ-09, REQ-10, REQ-11, REQ-12, REQ-13, REQ-14, REQ-15, REQ-16, REQ-17, REQ-18, REQ-19, REQ-20] partial: [] ---/ci---
78 lines
2.3 KiB
HTML
78 lines
2.3 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>CoreCI Broker</title>
|
|
<link rel="stylesheet" href="/ui/shared.css">
|
|
</head>
|
|
<body class="login-body">
|
|
<main class="login-card card">
|
|
<h1>CoreCI Broker</h1>
|
|
<p class="login-sub">Admin sign-in</p>
|
|
<form id="login-form">
|
|
<div class="field">
|
|
<label for="username">Username</label>
|
|
<input id="username" name="username" type="text" autocomplete="username" autofocus required>
|
|
</div>
|
|
<div class="field">
|
|
<label for="password">Password</label>
|
|
<input id="password" name="password" type="password" autocomplete="current-password" required>
|
|
</div>
|
|
<p class="form-error" id="login-error" role="alert" hidden></p>
|
|
<button type="submit" class="btn btn-primary btn-block" id="login-button">Sign in</button>
|
|
</form>
|
|
</main>
|
|
<script>
|
|
(function () {
|
|
var form = document.getElementById("login-form");
|
|
var error = document.getElementById("login-error");
|
|
var button = document.getElementById("login-button");
|
|
|
|
form.addEventListener("input", function () {
|
|
error.hidden = true;
|
|
error.textContent = "";
|
|
});
|
|
|
|
form.addEventListener("submit", async function (event) {
|
|
event.preventDefault();
|
|
error.hidden = true;
|
|
error.textContent = "";
|
|
button.disabled = true;
|
|
var status = 0;
|
|
var data = null;
|
|
try {
|
|
var response = await fetch("/api/broker/auth/login", {
|
|
method: "POST",
|
|
credentials: "same-origin",
|
|
headers: {"Content-Type": "application/json"},
|
|
body: JSON.stringify({
|
|
username: document.getElementById("username").value,
|
|
password: document.getElementById("password").value
|
|
})
|
|
});
|
|
status = response.status;
|
|
try {
|
|
data = await response.json();
|
|
} catch (parseError) {
|
|
data = null;
|
|
}
|
|
} catch (networkError) {
|
|
status = 0;
|
|
}
|
|
if (status === 200) {
|
|
location.href = "/ui/dashboard";
|
|
return;
|
|
}
|
|
if (status === 0) {
|
|
error.textContent = "Sign-in failed: broker unreachable.";
|
|
} else {
|
|
error.textContent = (data && data.message) || "Sign-in failed. Please try again.";
|
|
}
|
|
error.hidden = false;
|
|
button.disabled = false;
|
|
});
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html> |