gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit6f503cfc6f503cfctests/cdp.mjs: HL_CPU_THROTTLE=<rate> optional CPU throttling for gate runsmre6f503cfc/login.js

3.4 KB

  1. // login.js — the small bridge between ident's <ident-selector> and the tickets shell
  2. // (components/main.hl; ticket #7). Plain JS because hl:webex cannot listen to a custom DOM
  3. // event: `ident-login` (event.detail.code, the one-time code) goes into the hidden input
  4. // #identcode, whose `change` the shell handles (→ face identLogin, server-side exchange).
  5. // The host tells the selector whether this site is logged in: the shell keeps the
  6. // element's class at `in` / `out`, mirrored here into its `loggedIn` property
  7. // (= the `logged-in` attribute; false = reset to "choose ident").
  8. //
  9. // RUNS ONCE PER DOCUMENT (ticket #9, mission 012). hl:webex re-creates the shell's header
  10. // and its <script> elements whenever the login state flips (login, logout): the browser
  11. // then executes this file AGAIN, and the selector element is a NEW one. The old version
  12. // added one more `ident-login` listener per run, so after a logout ONE selection fired
  13. // two `change`s → two exchanges of the same one-time code → the second one failed
  14. // ("ident refused the login (400: unknown or already used code)") although the first
  15. // had logged the user in. Now: one guarded install, listeners on `document` (the event
  16. // bubbles and is composed), the CURRENT #selector looked up each time, and a code is
  17. // handed to the shell at most once.
  18. //
  19. // LOGIN BUTTON (ticket #10): just before the browser follows "Log in with ident", its
  20. // return URL gets `?next=<this page's path + query>`; /login/callback checks it
  21. // (same-origin path only) and sends the user back there.
  22. (() => {
  23. if (window.__ticketsLogin) { window.__ticketsLogin.sync(); return; }
  24. const selector = () => document.getElementById('selector');
  25. const sync = () => {
  26. const sel = selector();
  27. // not upgraded yet: a property set now would shadow the element's own accessor
  28. if (!sel || !window.customElements || !customElements.get('ident-selector')) return;
  29. const want = sel.classList.contains('in');
  30. if (sel.loggedIn !== want) sel.loggedIn = want;
  31. };
  32. // the class flips, and whole new selector elements arrive (hl:webex re-renders the header)
  33. new MutationObserver(sync).observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ['class'] });
  34. if (window.customElements) customElements.whenDefined('ident-selector').then(sync);
  35. const handed = new Set();
  36. document.addEventListener('ident-login', (e) => {
  37. const code = e.detail && e.detail.code;
  38. const input = document.getElementById('identcode');
  39. if (!input || !code || handed.has(code)) return; // a one-time code is exchanged once
  40. handed.add(code);
  41. input.value = code;
  42. input.dispatchEvent(new Event('change', { bubbles: true }));
  43. });
  44. // "Log in with ident": return to this page (the server accepts only a same-origin path)
  45. const withNext = (a) => {
  46. try {
  47. const u = new URL(a.href);
  48. const ret = new URL(u.searchParams.get('return'));
  49. const here = location.pathname + location.search;
  50. ret.search = '';
  51. if (here !== '/' && here.length <= 500) ret.searchParams.set('next', here);
  52. u.searchParams.set('return', ret.href);
  53. a.href = u.href;
  54. } catch (err) { /* keep the server's href: the login still works, it returns to / */ }
  55. };
  56. const onButton = (e) => {
  57. const a = e.target && e.target.closest && e.target.closest('#loginbutton');
  58. if (a) withNext(a);
  59. };
  60. for (const t of ['click', 'auxclick', 'contextmenu']) document.addEventListener(t, onButton, true);
  61. window.__ticketsLogin = { sync };
  62. })();

Branches

Latest commits

  • 6f503cfctests/cdp.mjs: HL_CPU_THROTTLE=<rate> optional CPU throttling for gate runsmre
  • e17e2855re-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
  • a6ddccd2re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
  • 81e036b7docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • 5d8d2cf6deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • 58e8c02cmission 024: report, LOG, STATUS, e2e fixmre
  • 50778073tests/e2e-route-marker.mjs: first paint marker, comments post/edit redrawmre
  • c5203298mission 024: MainMenu marks the page from the route (layouts 0bcc629 main-menu.hl); browser-side marker removed; gate: marker in the server HTMLmre
  • b1a4c270re-vendor Hybriel master f9614007: bin/ (git-ignored) and plugins wholemre
  • 866397a0mission 023: theme from layouts 76f99f6 (current marker, menu count badge), components from 3794c59 (MdEditor keys); Inbox count as badge, current by address; gates and E2E; reportmre
  • 7ed2e5e5deploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the script silently (grep under pipefail), as gitoria/layoutsmre
  • bf9064a3mission 022: tickets on the layouts theme (step 1): shell, styles, gates, audit, E2E; reportmre
  • f3d61711mission 022 WIP: tickets on the layouts theme (dbe3de7): AppHeader/MainMenu/UserMenu/Sidebar/ContentFirst shell, styles reduced to the app's own, check-theme in the gates, 390 audit + real-Chrome walk scriptmre
  • 31cabfccmission 021: E2E script, report, LOG, STATUSmre
  • 6aea8683editor look: .empty rule only for p.empty, files off where tickets has no upload, state note one line, events test scrolls the editor into view; synced md-editor (components d702d76+6f27ad3); gate 377/0, events 52/0mre
  • dce6ffa6Merge branch 'w28-deflake'mre
  • 536092a1tickets (mission 019): de-flake the m016 comment clicks (B: unliked) — calmClick waits until the button stops moving; test only, no app changemre
  • 9c5fd42amission 020: attachments E2E proof (lisbeth Chrome, real-data copy), reportmre
  • 1206404fREADME attachments, report 018, LOG/STATUSmre
  • 3d9e7f3ctests: m017 gate fixes (list count, waits before delete clicks); gate 373/0mre