23
Offline regression tests / windows (3.11) (push) Canceled after 0s
Offline regression tests / windows (3.12) (push) Canceled after 0s
Offline regression tests / windows (3.13) (push) Canceled after 0s

This commit is contained in:
listik committed 2026-10-23 21:42:13 +03:00
1 parent efd4e1dcf4
commit 3ae4e18211
4 files changed
+89 -19

No files matched your search

+10 -16
View File
@@ -129,15 +129,11 @@ main{{width:min(420px,calc(100% - 36px));background:#1a202c;border:1px solid #30
h1{{font-size:22px;margin:0 0 6px}}p{{color:#9aa9bf;font-size:14px}}label{{display:block;margin:16px 0 6px;color:#b9c7db}}
input{{box-sizing:border-box;width:100%;padding:11px;border-radius:7px;border:1px solid #39475a;background:#10141d;color:white;font-size:16px}}
button{{margin-top:20px;width:100%;padding:11px;border:0;border-radius:7px;background:#3b82f6;color:white;font-size:16px;cursor:pointer}}
.error{{color:#ff8b8b;min-height:20px}}.switch{{background:none;color:#80aaff;cursor:pointer;border:0}}
.error{{color:#ff8b8b;min-height:20px}}.note{{color:#9aa9bf;font-size:13px;margin-top:16px}}
</style><main><h1>Crypto Scam</h1><p id="modeText">Войдите в свой аккаунт</p><div class="error">{safe}</div>
<form method="post" action="/auth/login" id="authForm"><label>Логин</label><input name="username" required minlength="3" maxlength="32" autocomplete="username">
<form method="post" action="/auth/login"><label>Логин</label><input name="username" required minlength="3" maxlength="32" autocomplete="username">
<label>Пароль</label><input name="password" type="password" required minlength="12" maxlength="256" autocomplete="current-password">
<button id="submit">Войти</button></form><button class="switch" type="button" onclick="toggleMode()" id="switch">Создать аккаунт</button>
<script>let reg=false;function toggleMode(){{reg=!reg;document.getElementById('authForm').action=reg?'/auth/register':'/auth/login';
document.getElementById('submit').textContent=reg?'Зарегистрироваться':'Войти';document.getElementById('switch').textContent=reg?'Уже есть аккаунт? Войти':'Создать аккаунт';
document.getElementById('modeText').textContent=reg?'Создайте отдельный аккаунт с собственными сделками и API-ключами':'Войдите в свой аккаунт';
document.querySelector('[autocomplete="current-password"]').autocomplete=reg?'new-password':'current-password';}}</script></main></html>"""
<button>Войти</button></form><p class="note">Нового пользователя может создать администратор через SSH.</p></main></html>"""
return page.encode("utf-8")
@@ -251,21 +247,19 @@ class Gateway(BaseHTTPRequestHandler):
self._json(403, {"ok": False, "error": "Недоверенный запрос"})
return
path = self.path.partition("?")[0]
if path in ("/auth/login", "/auth/register"):
if path == "/auth/register":
self._send(403, _login_page("Регистрация через сайт отключена. Обратитесь к администратору."))
return
if path == "/auth/login":
if not self._auth_attempt_allowed():
self._send(429, _login_page("Слишком много попыток. Подождите 10 минут."))
return
try:
body = self._body()
username, password = str(body.get("username", "")), str(body.get("password", ""))
if path == "/auth/register":
user_id = STORE.register(username, password)
if STORE.mark_legacy_imported():
_import_legacy_data(STORE.data_dir(user_id))
else:
user_id = STORE.authenticate(username, password)
if user_id is None:
raise AuthError("Неверный логин или пароль")
user_id = STORE.authenticate(username, password)
if user_id is None:
raise AuthError("Неверный логин или пароль")
except (AuthError, ValueError, UnicodeError) as exc:
self._send(400, _login_page(str(exc)))
return