106 lines
3.6 KiB
HTML
106 lines
3.6 KiB
HTML
<!doctype html>
|
|
<html lang="ru">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>Market Assistant — доступ</title>
|
|
<!--
|
|
Отдельная страница входа, а не Vue-компонент: nginx (auth_request) не отдаёт
|
|
оболочку SPA без сессии, значит и форма должна жить ДО границы доступа.
|
|
Никаких ассетов и сборки — только fetch на POST /api/auth/login.
|
|
-->
|
|
<style>
|
|
:root { color-scheme: dark; }
|
|
* { box-sizing: border-box; }
|
|
body {
|
|
margin: 0;
|
|
background: #0b1220;
|
|
color: #d3deef;
|
|
font: 14px/1.45 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
|
|
display: flex;
|
|
min-height: 100vh;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 20px;
|
|
}
|
|
form {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
width: min(380px, 100%);
|
|
background: #0e1626;
|
|
border: 1px solid #1d2c47;
|
|
border-radius: 10px;
|
|
padding: 18px;
|
|
}
|
|
h1 { font-size: 18px; margin: 0; font-weight: 600; }
|
|
p { margin: 0; color: #8e9db8; font-size: 12px; }
|
|
input {
|
|
background: #1c2a42;
|
|
color: #d3deef;
|
|
border: 1px solid #2d4266;
|
|
border-radius: 6px;
|
|
padding: 8px 10px;
|
|
font: inherit;
|
|
}
|
|
button {
|
|
background: #1c2a42;
|
|
color: #d3deef;
|
|
border: 1px solid #2d4266;
|
|
border-radius: 6px;
|
|
padding: 7px 12px;
|
|
cursor: pointer;
|
|
font: inherit;
|
|
}
|
|
button:hover { background: #26375a; }
|
|
button:disabled { opacity: 0.5; cursor: default; }
|
|
.err { color: #f85149; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<form id="f">
|
|
<h1>Market Assistant</h1>
|
|
<p>Доступ по паролю (<code>APP_PASSWORD</code> на бэкенде). После входа браузер
|
|
получит сессионную cookie — без неё и страница, и <code>/api/*</code> закрыты.</p>
|
|
<input id="p" type="password" autocomplete="current-password" placeholder="Пароль" />
|
|
<button id="b" type="submit" disabled>Войти</button>
|
|
<p id="m" class="err"></p>
|
|
</form>
|
|
<script>
|
|
const f = document.getElementById('f');
|
|
const p = document.getElementById('p');
|
|
const b = document.getElementById('b');
|
|
const m = document.getElementById('m');
|
|
|
|
p.addEventListener('input', () => {
|
|
b.disabled = p.value.length === 0;
|
|
});
|
|
|
|
f.addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
b.disabled = true;
|
|
m.textContent = '';
|
|
try {
|
|
const r = await fetch('/api/auth/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ password: p.value }),
|
|
});
|
|
if (!r.ok) {
|
|
const j = await r.json().catch(() => null);
|
|
m.textContent = (j && j.error) || 'HTTP ' + r.status;
|
|
return;
|
|
}
|
|
// Сессия в куке — дальше nginx пустит в SPA, а бэкенд отдаст данные.
|
|
location.replace('/');
|
|
} catch (err) {
|
|
m.textContent = 'Бэкенд недоступен: ' + (err && err.message ? err.message : err);
|
|
} finally {
|
|
b.disabled = p.value.length === 0;
|
|
}
|
|
});
|
|
|
|
p.focus();
|
|
</script>
|
|
</body>
|
|
</html> |