gitoriaLog in with ident

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit2881119f2881119fcalendar mission 001 (4/4): code order — README layout + same-output test, STATUS, LOG, report; tests/letcount.py (sub-folders), tests/realdata-baseline.mjs, tests/realdata-compare.pymre2881119f/login.js

2.6 KB

  1. // login.js — the small bridge between ident's <ident-selector> and the calendar shell (components/main.hl; the same
  2. // as gitoria's login.js). Plain JS because hl:web cannot listen to a custom DOM event: `ident-login`
  3. // (event.detail.code, the one-time code) goes into the hidden input #identcode, whose `change` the shell handles
  4. // (→ face calendarLogin, server-side exchange). The shell keeps the selector element's class at `in` / `out`; it is
  5. // mirrored here into the selector's `loggedIn` (false = back to "choose ident").
  6. // BACK TO THE PAGE: the "Log in with ident" click gets `?next=<this page>` in its return URL (project.hl safePath).
  7. // RUNS ONCE PER DOCUMENT: hl:web re-creates the header and its <script>s when the login state flips, the
  8. // selector element is then a NEW one; listeners sit on `document`, the CURRENT #selector is looked up each
  9. // time, and a one-time code is handed to the shell at most once.
  10. (() => {
  11. if (window.__calendarLogin) { window.__calendarLogin.sync(); return; }
  12. const sync = () => {
  13. const sel = document.getElementById('selector');
  14. // not upgraded yet: a property set now would shadow the element's own accessor
  15. if (!sel || !window.customElements || !customElements.get('ident-selector')) return;
  16. const want = sel.classList.contains('in');
  17. if (sel.loggedIn !== want) sel.loggedIn = want;
  18. };
  19. new MutationObserver(sync).observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ['class'] });
  20. if (window.customElements) customElements.whenDefined('ident-selector').then(sync);
  21. const handed = new Set();
  22. document.addEventListener('ident-login', (e) => {
  23. const code = e.detail && e.detail.code;
  24. const input = document.getElementById('identcode');
  25. if (!input || !code || handed.has(code)) return; // a one-time code is exchanged once
  26. handed.add(code);
  27. input.value = code;
  28. input.dispatchEvent(new Event('change', { bubbles: true }));
  29. });
  30. const withNext = (a) => {
  31. try {
  32. const u = new URL(a.href);
  33. const ret = new URL(u.searchParams.get('return'));
  34. const here = location.pathname + location.search;
  35. ret.search = '';
  36. if (here !== '/' && here.length <= 500) ret.searchParams.set('next', here);
  37. u.searchParams.set('return', ret.href);
  38. a.href = u.href;
  39. } catch (err) { /* keep the server's href: the login still works, it returns to / */ }
  40. };
  41. const onButton = (e) => {
  42. const a = e.target && e.target.closest && e.target.closest('#loginbutton');
  43. if (a) withNext(a);
  44. };
  45. for (const t of ['click', 'auxclick', 'contextmenu']) document.addEventListener(t, onButton, true);
  46. window.__calendarLogin = { sync };
  47. })();

Branches

Latest commits

  • 2881119fcalendar mission 001 (4/4): code order — README layout + same-output test, STATUS, LOG, report; tests/letcount.py (sub-folders), tests/realdata-baseline.mjs, tests/realdata-compare.pymre
  • 3b2a4cd0calendar mission 001 (3/4): code order — let only where reassigned (147 dropped incl. components/month-view; 110 left: 67 reassigned, 43 loop-bound); gates 78/0 (3 of 4 runs; 1 known 'next month' flake) + 18/0, live-data run = step 2mre
  • f5ce6b1dcalendar mission 001 (2/4): code order — topics, map, thin faces: lib/util.hl, lib/events(-helpers).hl (+calendarView/settingsView/soonOf), lib/settings.hl, lib/users.hl (+userOfLoginCode, tagOf), lib/api(-helpers).hl; project.hl = map; login route takes &req/&sessions (failed-login reason now kept); gates 78/0 + 18/0mre
  • c6fbd011calendar mission 001 (1/4): code order — files moved: lib/events.hl, lib/users.hl, components/styles.hl (imports only); gates 78/0 + 18/0, live-data run identicalmre
  • d6c59290calendar: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, mpackdb 2cb7ae5e, http1 773de63e); gates 78/0 + 18/0mre
  • 7bd0337ccalendar: Hybriel master 190aa11d (fc838894 GC correctness, #126 closure scopes, #127); gates 78/0 + 18/0mre
  • ff41310ccalendar: Hybriel master 8efba065 (#126 memory, #48 lambda copy; audit: no & needed)mre
  • 14ba08c7antcolony#40: mission references point to the moved missionsmre
  • 99c73346antcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
  • 76edaa62calendar: Hybriel master ff51cf46 (re-vendor round, static workaround removed)mre
  • 90a3fc2cdeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
  • 6722b72ddeploy.sh: never send .git or .gitignore to Byrodinmre
  • be099807State of 2026-09-27, before the move to gitoriamre