Инцидент 2026-07-22: mail.ru отверг SMTP-пароль (нужен пароль ПРИЛОЖЕНИЯ, err 535) → письма с кодом не уходили; сообщение «Обратитесь к администратору» вводило в заблуждение (будто нужно одобрение — а по инвайту вход свободный). Первопричина = пароль mail.ru (env, действие владельца). Код-часть: - POST /api/resend-code + auth.resend_verification: повторная отправка кода неподтверждённому (спам/сбой SMTP), анти-энумерация (общий ответ), rate-limit 3/email + 10/IP за 15мин - кнопка «Не пришёл код? Отправить повторно» на шаге подтверждения - сообщение при сбое почты: «подтверждение администратора НЕ требуется, временный сбой, запросите код повторно» вместо «Обратитесь к администратору» - 6 red-green тестов; бамп 2026-07-22a Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
178 lines
9.3 KiB
HTML
178 lines
9.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ru">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Регистрация — Сметный ИИ-ассистент</title>
|
|
<style>
|
|
:root { --bg: #f5f0eb; --card: #fff; --text: #3a3a3a; --muted: #6b6b6b; --accent: #c4463a; --border: #d4c5b2; --radius: 10px; --green: #2d8a56; }
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
|
|
.card { background: var(--card); border-radius: var(--radius); padding: 2rem; width: 380px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
|
|
h1 { font-size: 1.2rem; margin-bottom: .3rem; }
|
|
.subtitle { color: var(--muted); font-size: .85rem; margin-bottom: 1.5rem; }
|
|
label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .85rem; }
|
|
input { width: 100%; padding: .6rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .9rem; margin-bottom: 1rem; font-family: inherit; }
|
|
input:focus { outline: none; border-color: var(--accent); }
|
|
button { width: 100%; padding: .7rem; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); font-size: .95rem; font-weight: 600; cursor: pointer; }
|
|
button:hover { background: #a83830; }
|
|
button:disabled { background: var(--border); cursor: not-allowed; }
|
|
.error { color: var(--accent); font-size: .85rem; margin-bottom: .5rem; display: none; }
|
|
.success { color: var(--green); font-size: .85rem; margin-bottom: .5rem; display: none; }
|
|
.link { color: var(--accent); text-decoration: none; font-size: .85rem; }
|
|
.link:hover { text-decoration: underline; }
|
|
.step { display: none; }
|
|
.step.active { display: block; }
|
|
|
|
/* ===== Тёмная тема (общая с чатом; выбор в localStorage['theme']) ===== */
|
|
html { color-scheme: light; }
|
|
:root[data-theme="dark"] {
|
|
color-scheme: dark;
|
|
--bg: #16140f; --card: #211d17; --text: #ece4d7; --muted: #a89c8a;
|
|
--accent: #d9695c; --border: #3a332a; --green: #3fa066;
|
|
}
|
|
:root[data-theme="dark"] .card { box-shadow: 0 2px 16px rgba(0,0,0,.5); }
|
|
:root[data-theme="dark"] input { background: #262019; color: var(--text); }
|
|
:root[data-theme="dark"] button:hover { background: #c2564a; }
|
|
#theme-fab { position: fixed; top: .8rem; right: .8rem; width: 38px; height: 38px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; font-size: 1rem; line-height: 1; }
|
|
</style>
|
|
<script>
|
|
(function(){try{var t=localStorage.getItem('theme');if(t!=='dark'&&t!=='light'){t=(window.matchMedia&&matchMedia('(prefers-color-scheme: dark)').matches)?'dark':'light';}document.documentElement.setAttribute('data-theme',t);}catch(e){}})();
|
|
function toggleTheme(){var n=document.documentElement.getAttribute('data-theme')==='dark'?'light':'dark';document.documentElement.setAttribute('data-theme',n);try{localStorage.setItem('theme',n);}catch(e){}applyThemeIcon();}
|
|
function applyThemeIcon(){var b=document.getElementById('theme-fab');if(b)b.textContent=document.documentElement.getAttribute('data-theme')==='dark'?'☀':'☾';}
|
|
document.addEventListener('DOMContentLoaded',applyThemeIcon);
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<button id="theme-fab" onclick="toggleTheme()" title="Светлая / тёмная тема" aria-label="Переключить тему">☾</button>
|
|
<div class="card">
|
|
<h1>Регистрация</h1>
|
|
<p class="subtitle">Сметный ИИ-ассистент</p>
|
|
|
|
<!-- Step 1: Email + Password -->
|
|
<div class="step active" id="step1">
|
|
<div class="error" id="err1"></div>
|
|
<label>Email</label>
|
|
<input type="email" id="reg-email" placeholder="your@email.com">
|
|
<label>Пароль</label>
|
|
<input type="password" id="reg-pass" placeholder="Минимум 6 символов">
|
|
<label>Повторите пароль</label>
|
|
<input type="password" id="reg-pass2" placeholder="Повторите пароль">
|
|
<div id="captcha-container" style="margin:.6rem 0"></div>
|
|
<button onclick="doRegister()">Зарегистрироваться</button>
|
|
<p style="margin-top:1rem;text-align:center"><a class="link" href="/">Уже есть аккаунт? Войти</a></p>
|
|
</div>
|
|
|
|
<!-- Step 2: Verification code -->
|
|
<div class="step" id="step2">
|
|
<div class="success" id="msg2"></div>
|
|
<div class="error" id="err2"></div>
|
|
<label>Код подтверждения</label>
|
|
<p style="color:var(--muted);font-size:.8rem;margin-bottom:.5rem">Код отправлен на <b id="sent-email"></b></p>
|
|
<input type="text" id="verify-code" placeholder="000000" maxlength="6" style="text-align:center;font-size:1.5rem;letter-spacing:8px">
|
|
<button onclick="doVerify()">Подтвердить</button>
|
|
<p style="text-align:center;margin-top:.7rem;font-size:.82rem">
|
|
<a class="link" href="#" onclick="doResend();return false">Не пришёл код? Отправить повторно</a>
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Step 3: Success -->
|
|
<div class="step" id="step3">
|
|
<div class="success" style="display:block">Email подтверждён! Можете войти.</div>
|
|
<br>
|
|
<button onclick="window.location.href='/'">Войти</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Get invite token from URL
|
|
const params = new URLSearchParams(window.location.search);
|
|
const inviteToken = params.get('invite') || '';
|
|
let regEmail = '';
|
|
|
|
// SmartCaptcha (Ф4): виджет рендерится ТОЛЬКО если сервер отдал sitekey
|
|
// (иначе капча выключена и блок пуст — поведение как раньше).
|
|
let captchaWidgetId = null;
|
|
fetch('/api/captcha-config').then(r => r.json()).then(cfg => {
|
|
if (!cfg.sitekey) return;
|
|
const s = document.createElement('script');
|
|
s.src = 'https://smartcaptcha.yandexcloud.net/captcha.js?render=onload&onload=onCaptchaReady';
|
|
s.defer = true;
|
|
window.onCaptchaReady = () => {
|
|
captchaWidgetId = window.smartCaptcha.render('captcha-container', {sitekey: cfg.sitekey});
|
|
};
|
|
document.head.appendChild(s);
|
|
}).catch(() => {});
|
|
|
|
function showStep(n) {
|
|
document.querySelectorAll('.step').forEach(s => s.classList.remove('active'));
|
|
document.getElementById('step' + n).classList.add('active');
|
|
}
|
|
|
|
async function doRegister() {
|
|
const email = document.getElementById('reg-email').value.trim();
|
|
const pass = document.getElementById('reg-pass').value;
|
|
const pass2 = document.getElementById('reg-pass2').value;
|
|
const err = document.getElementById('err1');
|
|
err.style.display = 'none';
|
|
|
|
if (!email || !pass) { err.textContent = 'Заполните все поля'; err.style.display = 'block'; return; }
|
|
if (pass !== pass2) { err.textContent = 'Пароли не совпадают'; err.style.display = 'block'; return; }
|
|
if (pass.length < 6) { err.textContent = 'Пароль минимум 6 символов'; err.style.display = 'block'; return; }
|
|
if (!inviteToken) { err.textContent = 'Нужна ссылка-приглашение от администратора'; err.style.display = 'block'; return; }
|
|
|
|
try {
|
|
const r = await fetch('/api/register', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({email, password: pass, invite: inviteToken,
|
|
captcha_token: (captchaWidgetId !== null && window.smartCaptcha)
|
|
? window.smartCaptcha.getResponse(captchaWidgetId) : ''}),
|
|
});
|
|
const data = await r.json();
|
|
if (!r.ok) { err.textContent = data.detail || 'Ошибка регистрации'; err.style.display = 'block'; return; }
|
|
|
|
regEmail = email;
|
|
document.getElementById('sent-email').textContent = email;
|
|
document.getElementById('msg2').textContent = data.message;
|
|
document.getElementById('msg2').style.display = 'block';
|
|
showStep(2);
|
|
} catch(e) { err.textContent = 'Ошибка сети'; err.style.display = 'block'; }
|
|
}
|
|
|
|
async function doResend() {
|
|
const err = document.getElementById('err2'), msg = document.getElementById('msg2');
|
|
err.style.display = 'none';
|
|
if (!regEmail) { err.textContent = 'Сначала зарегистрируйтесь'; err.style.display = 'block'; return; }
|
|
try {
|
|
const r = await fetch('/api/resend-code', {
|
|
method: 'POST', headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({email: regEmail}),
|
|
});
|
|
const d = await r.json();
|
|
msg.textContent = d.message || 'Код отправлен повторно.'; msg.style.display = 'block';
|
|
} catch (e) { err.textContent = 'Не удалось отправить. Попробуйте позже.'; err.style.display = 'block'; }
|
|
}
|
|
|
|
async function doVerify() {
|
|
const code = document.getElementById('verify-code').value.trim();
|
|
const err = document.getElementById('err2');
|
|
err.style.display = 'none';
|
|
|
|
if (!code) { err.textContent = 'Введите код'; err.style.display = 'block'; return; }
|
|
|
|
try {
|
|
const r = await fetch('/api/verify-email', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({email: regEmail, code}),
|
|
});
|
|
const data = await r.json();
|
|
if (!r.ok) { err.textContent = data.detail || 'Неверный код'; err.style.display = 'block'; return; }
|
|
showStep(3);
|
|
} catch(e) { err.textContent = 'Ошибка сети'; err.style.display = 'block'; }
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|