Skip to content

LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.

11.4 KB
Raw Blame
<!doctype html>
<html lang="en" translate="no">
<head>
<meta charset="utf-8">
<meta name="google" content="notranslate">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>LordOS · Remote desktop</title>
<style>
  /* Same look as the monitor's login screen (themes/greeter). No list of
     users: from the network we don't reveal who has an account on the machine. */
  :root { color-scheme: dark; }
  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body { margin: 0; overflow: hidden; font: 15px/1.4 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; color: #fff;
         background: #241326 url(/bg.jpg) center / cover no-repeat; user-select: none; }
  .top { position: absolute; left: 0; right: 0; top: 8.5vh; text-align: center; }
  .date { font-size: clamp(16px, 2.7vh, 26px); font-weight: 500; color: rgba(255,255,255,.88); }
  .clock { font-size: clamp(64px, 17vh, 170px); font-weight: 700; line-height: 1.05; color: rgba(255,255,255,.86);
           letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
  form { position: absolute; left: 0; right: 0; top: calc(60vh - 110px); display: flex; flex-direction: column; align-items: center; }
  .avatar { width: clamp(76px, 12vh, 110px); height: clamp(76px, 12vh, 110px); border-radius: 50%; display: grid; place-items: center;
            font-size: clamp(30px, 4.8vh, 44px); font-weight: 600; color: rgba(255,255,255,.95);
            background: linear-gradient(170deg, #a77bf3, #7a4fd6); border: 2px solid rgba(255,255,255,.35);
            box-shadow: 0 10px 30px rgba(0,0,0,.35); transition: background .3s; }
  .who { margin-top: 14px; font-size: 16px; font-weight: 600; min-height: 22px; text-shadow: 0 1px 6px rgba(0,0,0,.4); }
  .field { position: relative; margin-top: 10px; }
  input { width: 230px; height: 34px; padding: 0 38px 0 15px; border-radius: 17px; border: 1px solid rgba(255,255,255,.28);
          background: rgba(255,255,255,.16); color: #fff; font: inherit; font-size: 14px; outline: none; backdrop-filter: blur(8px); }
  input::placeholder { color: rgba(255,255,255,.55); }
  input:focus { border-color: rgba(255,255,255,.55); }
  button { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%; border: 0; padding: 0;
           background: rgba(255,255,255,.85); color: #3a2a4a; font-weight: 700; font-size: 13px; cursor: pointer; }
  .err { margin-top: 10px; min-height: 18px; font-size: 12px; color: #ffd2d2; text-align: center; max-width: 320px; }
  .shake { animation: shake .32s; }
  @keyframes shake { 0%,100% { transform: translateX(0) } 15% { transform: translateX(12px) } 30% { transform: translateX(-11px) }
                     45% { transform: translateX(9px) } 60% { transform: translateX(-7px) } 75% { transform: translateX(5px) } 90% { transform: translateX(-3px) } }
  .bl { position: absolute; left: 20px; bottom: 26px; font-size: 12px; color: rgba(255,255,255,.8); display: flex; gap: 7px; align-items: center; }
  .bl i { width: 13px; height: 9px; border: 1.4px solid rgba(255,255,255,.75); border-radius: 2px; display: inline-block; }
  .br { position: absolute; right: 20px; bottom: 20px; display: flex; gap: 8px; }
  .pill { height: 26px; padding: 0 10px; border-radius: 13px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.1);
          color: rgba(255,255,255,.85); font: 600 12px Inter, system-ui, sans-serif; cursor: pointer; position: static; width: auto; }
  .pill[aria-pressed=true] { background: rgba(255,255,255,.28); }
  .foot { position: absolute; left: 0; right: 0; bottom: 64px; text-align: center; font-size: 11px; color: rgba(255,255,255,.5); padding: 0 16px; }
  @media (max-height: 560px) { .top { top: 3vh } form { top: 40vh } .foot { display: none } }
</style>
</head>
<body>
<div class="top"><div class="date" id="date"></div><div class="clock" id="clock"></div></div>
<form method="post" action="/login" enctype="application/x-www-form-urlencoded" accept-charset="UTF-8" autocomplete="on" novalidate id="f">
  <div class="avatar" id="av">👑</div>
  <div class="who" id="who"></div>
  <div class="field"><input id="user" name="user" type="text" autocomplete="username" autocapitalize="none" autocorrect="off" spellcheck="false" inputmode="text" maxlength="32" pattern="[a-z_][a-z0-9_\-]{0,31}" required autofocus></div>
  <div class="field" id="pf"><input id="pass" name="pass" type="password" autocomplete="current-password" minlength="1" maxlength="1024" required><button type="submit" id="go" aria-label="→">→</button></div>
  <div class="err" id="err" role="alert" aria-live="polite"></div>
</form>
<div class="foot" id="foot"></div>
<div class="bl"><i></i><span id="host"></span></div>
<div class="br"><button type="button" class="pill" data-l="es">ES</button><button type="button" class="pill" data-l="en">EN</button><button type="button" class="pill" data-l="pt">PT</button></div>
<script>
  const L = {
    en: { user: 'Username', pass: 'Password', e1: 'Wrong username or password.', e2: 'Too many attempts. Wait a while and try again.',
          e3: 'The session was locked. Sign in again.',
          e4: 'Too many failed attempts from this computer: it is blocked for a while. An administrator can unblock it in Settings → Sharing.',
          e5: 'User names use lowercase letters, digits, - and _ (up to 32).', e6: 'Enter your password.',
          foot: 'LordOS remote desktop · encrypted connection. If your browser warns about the certificate, compare its fingerprint with Settings → Sharing.',
          days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
          months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
          date: (w, d, m) => `${w}, ${m} ${d}`, h12: true },
    es: { user: 'Usuario', pass: 'Contraseña', e1: 'Usuario o contraseña incorrectos.', e2: 'Demasiados intentos. Esperá un rato y probá de nuevo.',
          e3: 'La sesión se bloqueó. Volvé a ingresar.',
          e4: 'Demasiados intentos fallidos desde esta computadora: quedó bloqueada por un rato. Un administrador puede desbloquearla en Ajustes → Compartir.',
          e5: 'Los nombres de usuario usan minúsculas, números, - y _ (hasta 32).', e6: 'Escribí tu contraseña.',
          foot: 'Escritorio remoto de LordOS · conexión cifrada. Si el navegador avisa del certificado, compará su huella con la de Ajustes → Compartir.',
          days: ['domingo', 'lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado'],
          months: ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'],
          date: (w, d, m) => `${w}, ${d} de ${m}`, h12: false },
    pt: { user: 'Usuário', pass: 'Senha', e1: 'Usuário ou senha incorretos.', e2: 'Muitas tentativas. Espere um pouco e tente de novo.',
          e3: 'A sessão foi bloqueada. Entre de novo.',
          e4: 'Muitas tentativas falhas deste computador: ele foi bloqueado por um tempo. Um administrador pode desbloqueá-lo em Ajustes → Compartilhar.',
          e5: 'Nomes de usuário usam letras minúsculas, números, - e _ (até 32).', e6: 'Digite sua senha.',
          foot: 'Área de trabalho remota do LordOS · conexão criptografada. Se o navegador avisar do certificado, compare a impressão digital com Ajustes → Compartilhar.',
          days: ['domingo', 'segunda-feira', 'terça-feira', 'quarta-feira', 'quinta-feira', 'sexta-feira', 'sábado'],
          months: ['janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro'],
          date: (w, d, m) => `${w}, ${d} de ${m}`, h12: false },
  };
  const $ = (id) => document.getElementById(id);
  let lang = (() => { try { return localStorage.getItem('lordos-lang'); } catch (e) { return null; } })() || (navigator.language || 'en').slice(0, 2);
  if (!L[lang]) lang = 'en';
  const PAL = [['#5b9cff', '#2f6fe0'], ['#f0915a', '#d0602b'], ['#4cc37a', '#269653'], ['#e0609d', '#b83574'], ['#a77bf3', '#7a4fd6'], ['#4cc4d3', '#2391a3'], ['#f2c14e', '#d0961d']];
  const hash = (s) => { let h = 0; for (const c of s) h = (h * 31 + c.codePointAt(0)) >>> 0; return h; };
  function apply() {
    const t = L[lang];
    document.documentElement.lang = lang;
    $('user').placeholder = t.user;
    $('pass').placeholder = t.pass;
    $('foot').textContent = t.foot;
    // the error comes in the URL (?e=1, after a redirect) or, when the server can't redirect (this
    // computer just got blocked), on <html data-e>; only these fixed codes are shown
    const e = errCode();
    $('err').textContent = ['1', '2', '3', '4', '5', '6'].includes(e) ? t['e' + e] : '';
    if (e === '4') { $('user').disabled = true; $('pass').disabled = true; $('go').disabled = true; }
    for (const b of document.querySelectorAll('.pill')) b.setAttribute('aria-pressed', String(b.dataset.l === lang));
    tick();
  }
  function tick() {
    const t = L[lang], d = new Date();
    const w = t.days[d.getDay()];
    $('date').textContent = t.date(w[0].toUpperCase() + w.slice(1), d.getDate(), t.months[d.getMonth()]);
    let h = d.getHours();
    const m = String(d.getMinutes()).padStart(2, '0');
    if (t.h12) { const ap = h < 12 ? 'AM' : 'PM'; h = h % 12 || 12; $('clock').textContent = `${h}:${m} ${ap}`; }
    else $('clock').textContent = `${String(h).padStart(2, '0')}:${m}`;
  }
  // the avatar follows the name being typed (initials and a fixed color per name)
  $('user').addEventListener('input', () => {
    const u = $('user').value.trim().toLowerCase();
    $('who').textContent = u;
    $('av').textContent = u ? u[0].toUpperCase() : '👑';
    const [a, b] = u ? PAL[hash(u) % PAL.length] : ['#a77bf3', '#7a4fd6'];
    $('av').style.background = `linear-gradient(170deg, ${a}, ${b})`;
  });
  for (const b of document.querySelectorAll('.pill')) b.addEventListener('click', () => {
    lang = b.dataset.l;
    try { localStorage.setItem('lordos-lang', lang); } catch (e) { /* no storage */ }
    apply();
  });
  const ERR = document.documentElement.dataset.e || new URLSearchParams(location.search).get('e') || '';
  function errCode() { return ERR; }
  const NAME = /^[a-z_][a-z0-9_-]{0,31}$/;
  // Checked here for a quick answer; the server checks everything again. The user name is kept in
  // this tab's sessionStorage across the error page (never in the URL), the password never.
  $('f').addEventListener('submit', (ev) => {
    const u = $('user').value, p = $('pass').value, enc = new TextEncoder().encode(p).length;
    let bad = '';
    if (!NAME.test(u)) bad = '5';
    else if (!p || enc > 1024 || p.includes('\0')) bad = '6';
    if (bad) {
      ev.preventDefault();
      $('err').textContent = L[lang]['e' + bad];
      $('pf').classList.remove('shake'); void $('pf').offsetWidth; $('pf').classList.add('shake');
      (bad === '5' ? $('user') : $('pass')).focus();
      return;
    }
    try { sessionStorage.setItem('lordos-user', u); } catch (e) { /* no storage */ }
    $('go').disabled = true;
  });
  $('host').textContent = location.hostname;
  let prev = '';
  try { prev = sessionStorage.getItem('lordos-user') || ''; } catch (e) { /* no storage */ }
  if (errCode() && NAME.test(prev)) { $('user').value = prev; $('user').dispatchEvent(new Event('input')); }
  if (location.search) history.replaceState(null, '', '/');     // nothing stays in the address bar
  apply();
  setInterval(tick, 1000);
  if (errCode()) { $('pf').classList.add('shake'); if (!$('pass').disabled) $('pass').focus(); }
</script>
</body>
</html>