Bound credentials, brake password changes, cap bug reports, page the user list, structure every error (B-94, SEC-54, SEC-55, API-09, API-15, API-16, API-19, API-21, API-28, API-33, REG-12, AUD-42)

- login and password-change fields: at most 256 characters
- wrong current password: per-user brake (5 free, 2s doubling to 300s), 429 even for the
  right password while locked; password_changed audited in the same transaction
- POST /bug-reports: 10 per IP per hour, consumed only by a stored report
- GET /admin/users: limit/after_id paging, the panel walks the pages
- 401/403/404/405/422/503 all answer {code, message, params}; the 422 omits the input
- static files revalidated on every use (Cache-Control: no-cache)
- error.* keys for the new codes in all seven languages

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
davideandClaude Sonnet 5.5 committed 2026-10-18 00:59:25 +02:00
1 parent c1b192f6d1
commit 24e5fc3d8b
23 files changed
+374 -111

No files matched your search

+10 -3
View File
@@ -34,8 +34,8 @@ async function callAdmin(method, path, body) {
const headers = { 'Content-Type': 'application/json', 'X-Admin-Token': adminToken };
const res = await fetch(path, { method, headers, body: body ? JSON.stringify(body) : undefined });
const data = await res.json().catch(() => ({}));
// detail is a bare string on the admin endpoints, but the shared dependencies
// (auth) answer with the structured {code, message} form of app/api/errors.py.
// Every error answers with the structured {code, message, params} detail (API-16);
// the bare-string fallback only covers a proxy's own error page.
if (!res.ok) throw new Error(data.detail?.message || data.detail || res.statusText);
return data;
}
@@ -230,7 +230,14 @@ async function adminSave() {
async function loadUsers() {
try {
const users = await callAdmin('GET', '/admin/users');
// B-94 (API-33): the list comes in pages of up to 500, by ascending id.
const users = [];
for (;;) {
const afterId = users.length ? users[users.length - 1].id : 0;
const page = await callAdmin('GET', `/admin/users?limit=500&after_id=${afterId}`);
users.push(...page);
if (page.length < 500) break;
}
const tbody = document.getElementById('users-tbody');
tbody.innerHTML = users.map((u) => `
<tr>
+1 -1
View File
@@ -87,7 +87,7 @@ async function call(method, path, body) {
// A token the server no longer accepts can't be recovered from by retrying:
// without this every poll keeps failing against a dashboard that still looks
// logged in, toasting "session expired" forever. Drop back to the login form.
if (res.status === 401 && data.detail?.code === 'session_expired' && token) logout();
if (res.status === 401 && ['session_expired', 'not_authenticated'].includes(data.detail?.code) && token) logout();
throw new Error(apiErrorMessage(data.detail) || res.statusText);
}
return data;
+49
View File
@@ -162,6 +162,13 @@ const TRANSLATIONS = {
'error.broadcast_failed': 'The network refused the transaction. Please try again shortly.',
'error.service_busy': 'The service is busy right now and nothing was sent. Please try again in a moment.',
'error.registration_unavailable': 'Registration is temporarily unavailable. Please try again later.',
'error.not_authenticated': 'You are not signed in. Please sign in again.',
'error.not_found': 'Not found.',
'error.method_not_allowed': 'This action is not allowed.',
'error.too_many_streams': 'Too many live-update connections right now; the page will keep refreshing on its own.',
'error.invalid_admin_token': 'The admin token is missing or wrong.',
'error.user_not_found': 'User not found.',
'error.bug_report_not_found': 'Bug report not found.',
'error.amount_below_dust_limit': 'The amount is too small to be sent.',
'error.too_many_inputs': 'Your balance is split across too many small deposits to be spent in a single transaction (max {max_inputs}). Please contact support to consolidate it.',
'error.withdrawal_to_own_address': 'That is your own deposit address — withdraw to an external wallet.',
@@ -331,6 +338,13 @@ const TRANSLATIONS = {
'error.broadcast_failed': 'La rete ha rifiutato la transazione. Riprova tra poco.',
'error.service_busy': 'Il servizio è occupato in questo momento e non è stato inviato nulla. Riprova tra poco.',
'error.registration_unavailable': 'La registrazione è temporaneamente non disponibile. Riprova più tardi.',
'error.not_authenticated': 'Non hai effettuato l\'accesso. Accedi di nuovo.',
'error.not_found': 'Non trovato.',
'error.method_not_allowed': 'Questa azione non è consentita.',
'error.too_many_streams': 'Troppe connessioni di aggiornamento in tempo reale; la pagina continuerà ad aggiornarsi da sola.',
'error.invalid_admin_token': 'Il token admin manca o è errato.',
'error.user_not_found': 'Utente non trovato.',
'error.bug_report_not_found': 'Segnalazione non trovata.',
'error.amount_below_dust_limit': "L'importo è troppo basso per essere inviato.",
'error.too_many_inputs': 'Il tuo saldo è suddiviso in troppi piccoli depositi per essere speso in una sola transazione (max {max_inputs}). Contatta l\'assistenza per consolidarlo.',
'error.withdrawal_to_own_address': 'Questo è il tuo indirizzo di deposito — preleva verso un wallet esterno.',
@@ -500,6 +514,13 @@ const TRANSLATIONS = {
'error.broadcast_failed': 'La red rechazó la transacción. Inténtalo de nuevo en un momento.',
'error.service_busy': 'El servicio está ocupado en este momento y no se ha enviado nada. Inténtalo de nuevo en un momento.',
'error.registration_unavailable': 'El registro no está disponible temporalmente. Inténtalo de nuevo más tarde.',
'error.not_authenticated': 'No has iniciado sesión. Inicia sesión de nuevo.',
'error.not_found': 'No encontrado.',
'error.method_not_allowed': 'Esta acción no está permitida.',
'error.too_many_streams': 'Demasiadas conexiones de actualización en tiempo real; la página seguirá actualizándose sola.',
'error.invalid_admin_token': 'Falta el token de administrador o es incorrecto.',
'error.user_not_found': 'Usuario no encontrado.',
'error.bug_report_not_found': 'Informe de error no encontrado.',
'error.amount_below_dust_limit': 'El importe es demasiado pequeño para enviarse.',
'error.too_many_inputs': 'Tu saldo está repartido en demasiados depósitos pequeños para gastarse en una sola transacción (máx. {max_inputs}). Contacta con soporte para consolidarlo.',
'error.withdrawal_to_own_address': 'Esa es tu propia dirección de depósito — retira a una cartera externa.',
@@ -669,6 +690,13 @@ const TRANSLATIONS = {
'error.broadcast_failed': 'Le réseau a refusé la transaction. Veuillez réessayer dans un instant.',
'error.service_busy': 'Le service est occupé pour le moment et rien n\'a été envoyé. Veuillez réessayer dans un instant.',
'error.registration_unavailable': 'L\'inscription est temporairement indisponible. Veuillez réessayer plus tard.',
'error.not_authenticated': 'Vous n\'êtes pas connecté. Veuillez vous reconnecter.',
'error.not_found': 'Introuvable.',
'error.method_not_allowed': 'Cette action n\'est pas autorisée.',
'error.too_many_streams': 'Trop de connexions de mise à jour en direct ; la page continuera de s\'actualiser seule.',
'error.invalid_admin_token': 'Le jeton d\'administration est absent ou incorrect.',
'error.user_not_found': 'Utilisateur introuvable.',
'error.bug_report_not_found': 'Signalement introuvable.',
'error.amount_below_dust_limit': "Le montant est trop faible pour être envoyé.",
'error.too_many_inputs': 'Votre solde est réparti sur trop de petits dépôts pour être dépensé en une seule transaction (max {max_inputs}). Contactez le support pour le consolider.',
'error.withdrawal_to_own_address': "C'est votre propre adresse de dépôt — retirez vers un portefeuille externe.",
@@ -838,6 +866,13 @@ const TRANSLATIONS = {
'error.broadcast_failed': 'Das Netzwerk hat die Transaktion abgelehnt. Bitte versuche es in Kürze erneut.',
'error.service_busy': 'Der Dienst ist gerade ausgelastet und es wurde nichts gesendet. Bitte versuche es gleich noch einmal.',
'error.registration_unavailable': 'Die Registrierung ist vorübergehend nicht verfügbar. Bitte versuche es später noch einmal.',
'error.not_authenticated': 'Du bist nicht angemeldet. Bitte melde dich erneut an.',
'error.not_found': 'Nicht gefunden.',
'error.method_not_allowed': 'Diese Aktion ist nicht erlaubt.',
'error.too_many_streams': 'Zu viele Live-Update-Verbindungen; die Seite aktualisiert sich weiterhin selbst.',
'error.invalid_admin_token': 'Das Admin-Token fehlt oder ist falsch.',
'error.user_not_found': 'Benutzer nicht gefunden.',
'error.bug_report_not_found': 'Fehlermeldung nicht gefunden.',
'error.amount_below_dust_limit': 'Der Betrag ist zu klein, um gesendet zu werden.',
'error.too_many_inputs': 'Ihr Guthaben ist auf zu viele kleine Einzahlungen verteilt, um in einer einzigen Transaktion ausgegeben zu werden (max. {max_inputs}). Bitte wenden Sie sich an den Support, um es zusammenzufassen.',
'error.withdrawal_to_own_address': 'Das ist deine eigene Einzahlungsadresse — zahle auf eine externe Wallet aus.',
@@ -1007,6 +1042,13 @@ const TRANSLATIONS = {
'error.broadcast_failed': 'Сеть отклонила транзакцию. Попробуйте ещё раз через минуту.',
'error.service_busy': 'Сервис сейчас занят, ничего не было отправлено. Попробуйте ещё раз через минуту.',
'error.registration_unavailable': 'Регистрация временно недоступна. Попробуйте позже.',
'error.not_authenticated': 'Вы не вошли в систему. Войдите снова.',
'error.not_found': 'Не найдено.',
'error.method_not_allowed': 'Это действие не разрешено.',
'error.too_many_streams': 'Слишком много соединений для живых обновлений; страница продолжит обновляться сама.',
'error.invalid_admin_token': 'Токен администратора отсутствует или неверен.',
'error.user_not_found': 'Пользователь не найден.',
'error.bug_report_not_found': 'Сообщение об ошибке не найдено.',
'error.amount_below_dust_limit': 'Сумма слишком мала для отправки.',
'error.too_many_inputs': 'Ваш баланс разбит на слишком много мелких депозитов, чтобы потратить его одной транзакцией (максимум {max_inputs}). Обратитесь в поддержку для консолидации.',
'error.withdrawal_to_own_address': 'Это ваш собственный адрес для депозита — выводите на внешний кошелёк.',
@@ -1176,6 +1218,13 @@ const TRANSLATIONS = {
'error.broadcast_failed': '网络拒绝了该交易,请稍后重试。',
'error.service_busy': '服务当前繁忙,没有发送任何内容,请稍后重试。',
'error.registration_unavailable': '注册暂时不可用,请稍后再试。',
'error.not_authenticated': '您尚未登录,请重新登录。',
'error.not_found': '未找到。',
'error.method_not_allowed': '不允许此操作。',
'error.too_many_streams': '实时更新连接过多;页面将自行继续刷新。',
'error.invalid_admin_token': '管理员令牌缺失或错误。',
'error.user_not_found': '未找到用户。',
'error.bug_report_not_found': '未找到错误报告。',
'error.amount_below_dust_limit': '金额过小,无法发送。',
'error.too_many_inputs': '您的余额分散在过多的小额存款中,无法在一笔交易中花费(最多 {max_inputs} 笔)。请联系客服进行归集。',
'error.withdrawal_to_own_address': '这是你自己的充值地址 — 请提现到外部钱包。',