Registro di casa 192.168.30.23:3000 (HTTP) nel modello Unraid, in compose e nel rilascio con buildx; profilo seccomp fuori da /dati. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
53 lines
2.4 KiB
JavaScript
53 lines
2.4 KiB
JavaScript
// The login page of the Docker interface (spec §13.1): one password, an HttpOnly SameSite=Strict session cookie set
|
|
// by the server, lockout after repeated failures. Nothing is stored by this page.
|
|
|
|
import { h, fill, brand } from './core/dom.js';
|
|
import { loadTexts, t } from './core/text.js';
|
|
import { returnAddress } from './core/return-path.js';
|
|
|
|
async function boot() {
|
|
await loadTexts('it');
|
|
const root = document.getElementById('app');
|
|
const password = h('input', { type: 'password', id: 'password', autocomplete: 'current-password', required: true, autofocus: true });
|
|
const message = h('p.aiuto', { role: 'alert', style: { color: 'var(--rosso)', minHeight: '20px' } });
|
|
const button = h('button.btn.primo.grande', { type: 'submit', style: { width: '100%', justifyContent: 'center' } }, t('accesso.entra'));
|
|
const form = h('form.pannello', { style: { width: 'min(360px, calc(100vw - 32px))', padding: '28px', display: 'flex', flexDirection: 'column', gap: '12px' } },
|
|
h('div.marchio', { style: { padding: '0 0 6px' } }, brand(), h('b', t('app.nome'))),
|
|
h('h1', { style: { margin: '0', fontSize: '20px', fontWeight: '650' } }, t('accesso.titolo')),
|
|
h('label.etichetta', { for: 'password' }, t('accesso.password')),
|
|
h('div.campo', password),
|
|
h('p.aiuto', t('accesso.aiuto')),
|
|
message,
|
|
button);
|
|
form.addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
button.disabled = true;
|
|
message.textContent = '';
|
|
try {
|
|
const response = await fetch('/api/accesso', {
|
|
method: 'POST',
|
|
credentials: 'same-origin',
|
|
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
body: JSON.stringify({ password: password.value }),
|
|
});
|
|
const data = await response.json().catch(() => ({}));
|
|
if (response.ok && data.ok) {
|
|
// Back to the page Alberto was opening: only a page of this interface, never another site.
|
|
location.href = returnAddress(new URLSearchParams(location.search).get('torna'), location.origin);
|
|
return;
|
|
}
|
|
message.textContent = data.message || t('accesso.sbagliata');
|
|
password.value = '';
|
|
password.focus();
|
|
} catch {
|
|
message.textContent = t('comune.errore');
|
|
} finally {
|
|
button.disabled = false;
|
|
}
|
|
});
|
|
root.style.cssText = 'min-height:100vh;display:flex;align-items:center;justify-content:center;padding:16px';
|
|
fill(root, form);
|
|
}
|
|
|
|
boot();
|