This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user