This commit is contained in:
@@ -42,6 +42,7 @@ button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px
|
||||
.login-form input, .context-form input { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: #0b110e; transition: border-color .18s, background .18s; }
|
||||
.login-form input:hover, .context-form input:hover { border-color: var(--faint); }
|
||||
.login-form input { height: 52px; padding: 0 50px 0 14px; font-family: var(--mono); }
|
||||
.login-form input:not(#creator-password) { padding-right: 14px; margin-bottom: 16px; }
|
||||
.secret-row { position: relative; }
|
||||
.secret-row .icon-button { position: absolute; right: 7px; top: 7px; }
|
||||
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); background: transparent; border-radius: var(--radius); cursor: pointer; transition: background .18s, border-color .18s; }
|
||||
|
||||
@@ -99,18 +99,23 @@ function endSession(message = "Сессия завершена.") {
|
||||
loginForm.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
const button = byId("login-button");
|
||||
const bootstrap = byId("bootstrap-token").value.trim();
|
||||
const username = byId("creator-username").value.trim();
|
||||
const password = byId("creator-password").value;
|
||||
loginError.textContent = "";
|
||||
button.disabled = true;
|
||||
button.firstElementChild.textContent = "Проверяю ключ…";
|
||||
button.firstElementChild.textContent = "Проверяю данные…";
|
||||
try {
|
||||
const result = await request("/api/session", {method: "POST", headers: {Authorization: `Bearer ${bootstrap}`}});
|
||||
const result = await request("/api/session", {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({username, password})
|
||||
});
|
||||
sessionToken = result.Token;
|
||||
sessionStorage.setItem("domovoy.creator.session", sessionToken);
|
||||
byId("bootstrap-token").value = "";
|
||||
byId("creator-password").value = "";
|
||||
await showConsole();
|
||||
} catch (error) {
|
||||
loginError.textContent = error.message === "creator authentication denied" ? "Ключ не принят." : error.message;
|
||||
loginError.textContent = error.message === "creator authentication denied" ? "Логин или пароль не принят." : error.message;
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
button.firstElementChild.textContent = "Открыть консоль";
|
||||
@@ -118,9 +123,10 @@ loginForm.addEventListener("submit", async (event) => {
|
||||
});
|
||||
|
||||
byId("toggle-secret").addEventListener("click", () => {
|
||||
const input = byId("bootstrap-token");
|
||||
const input = byId("creator-password");
|
||||
input.type = input.type === "password" ? "text" : "password";
|
||||
byId("toggle-secret").setAttribute("aria-label", input.type === "password" ? "Показать ключ" : "Скрыть ключ");
|
||||
byId("toggle-secret").setAttribute("aria-label", input.type === "password" ? "Показать пароль" : "Скрыть пароль");
|
||||
byId("toggle-secret").setAttribute("title", input.type === "password" ? "Показать пароль" : "Скрыть пароль");
|
||||
});
|
||||
|
||||
contextForm.addEventListener("submit", (event) => {
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
<div class="brand-mark" aria-hidden="true">Д</div>
|
||||
<p class="eyebrow">защищённый вход · creator</p>
|
||||
<h1 id="login-title">Домовой</h1>
|
||||
<p class="login-copy">Личная операторская консоль. Ключ используется только для выпуска ограниченной сессии и не сохраняется браузером.</p>
|
||||
<p class="login-copy">Личная операторская консоль. Учётные данные используются только для выпуска ограниченной сессии и не сохраняются браузером.</p>
|
||||
<form id="login-form" class="login-form">
|
||||
<label for="bootstrap-token">Ключ создателя</label>
|
||||
<label for="creator-username">Логин</label>
|
||||
<input id="creator-username" name="username" type="text" autocomplete="username" required autofocus>
|
||||
<label for="creator-password">Пароль</label>
|
||||
<div class="secret-row">
|
||||
<input id="bootstrap-token" name="token" type="password" autocomplete="current-password" required autofocus>
|
||||
<button class="icon-button" id="toggle-secret" type="button" aria-label="Показать ключ" title="Показать ключ">
|
||||
<input id="creator-password" name="password" type="password" autocomplete="current-password" required>
|
||||
<button class="icon-button" id="toggle-secret" type="button" aria-label="Показать пароль" title="Показать пароль">
|
||||
<span aria-hidden="true">◉</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user