gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf03b438af03b438atickets header: the selector alone top right plus your name and Log out as before the theme missions; the user icon is gonemref03b438a/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

  • f03b438atickets header: the selector alone top right plus your name and Log out as before the theme missions; the user icon is gonemre
  • 81f10e4eident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
  • f51029abMerge branch 'sy-sync'mre
  • eae6e8c7sync components.hybriel 4922f9c: comments like / Edit / Delete / 'edited' are 44 px targets; gate: 'edited' hit-area padding, thread targets check (SY)mre
  • 0de4750btheme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 4eeb7bfeST2 report wordingmre
  • 2558f56cst2-sec: keep the hlsid session cookie name (no one is signed out), Secure flag only; gate: a cookie issued by main stays signed in; ident stub serves selector.js; security.mjs in deploy GATESmre
  • ea2e440esecurity audit (ST): JSON body cap, relation rights, login session rotation, __Host- Secure cookie, API security headers, CSP+referrer meta, /connect cap, one-line subjects, tests/security.mjs, reportmre
  • 7c8c2282sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • b6277497report MT-mobile, LOGmre
  • 6709398blist paging: the newest rows come first (the sorted array was not used); filter rows hide their scrollbar; gate checks the ordermre
  • 31736a80gate: member-name check fails on the old row layout toomre
  • e03ae537gate: the phone checks run on without the Show more button (so old code reports every failed check)mre
  • adf7f132gate: 390 px checks for the mobile audit fixes (row number, filters, field widths, Edit, member names, relation taps, paging)mre
  • 28e9c938ticket list: draw the newest 50 rows and a Show more button (500 rows were a 2-4 s first paint, 740 KB, a 90 000 px phone page)mre
  • ccebb0c7mobile: ticket number stays on one line, filter chips one scrolling row, fields full width under their caption, Edit/action buttons, member names whole, 44 px relation linksmre
  • f2dc7741gate: the phone toolbar is two even rows (E2)mre
  • 20f7c33async components.hybriel 214c318: MdEditor on a phone, two even toolbar rows of 44 px targets, label 15 px, table head 16 px (E2)mre
  • d74a5482sync components.hybriel 134b4e3: MdEditor builds an editor put into the page at once, redraws a surface put in anew (F5, hybriel#211)mre
  • 9d02c540sync components.hybriel 6b0936a: the 'edited' foldable drops the theme's border and marginmre