tickets
All repositories: gitoria
3.4 KB
// login.js — the small bridge between ident's <ident-selector> and the tickets shell// (components/main.hl; ticket #7). Plain JS because hl:webex cannot listen to a custom DOM// event: `ident-login` (event.detail.code, the one-time code) goes into the hidden input// #identcode, whose `change` the shell handles (→ face identLogin, server-side exchange).// The host tells the selector whether this site is logged in: the shell keeps the// element's class at `in` / `out`, mirrored here into its `loggedIn` property// (= the `logged-in` attribute; false = reset to "choose ident").//// RUNS ONCE PER DOCUMENT (ticket #9, mission 012). hl:webex re-creates the shell's header// and its <script> elements whenever the login state flips (login, logout): the browser// then executes this file AGAIN, and the selector element is a NEW one. The old version// added one more `ident-login` listener per run, so after a logout ONE selection fired// two `change`s → two exchanges of the same one-time code → the second one failed// ("ident refused the login (400: unknown or already used code)") although the first// had logged the user in. Now: one guarded install, listeners on `document` (the event// bubbles and is composed), the CURRENT #selector looked up each time, and a code is// handed to the shell at most once.//// LOGIN BUTTON (ticket #10): just before the browser follows "Log in with ident", its// return URL gets `?next=<this page's path + query>`; /login/callback checks it// (same-origin path only) and sends the user back there.(() => {if (window.__ticketsLogin) { window.__ticketsLogin.sync(); return; }const selector = () => document.getElementById('selector');const sync = () => {const sel = selector();// not upgraded yet: a property set now would shadow the element's own accessorif (!sel || !window.customElements || !customElements.get('ident-selector')) return;const want = sel.classList.contains('in');if (sel.loggedIn !== want) sel.loggedIn = want;};// the class flips, and whole new selector elements arrive (hl:webex re-renders the header)new MutationObserver(sync).observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ['class'] });if (window.customElements) customElements.whenDefined('ident-selector').then(sync);const handed = new Set();document.addEventListener('ident-login', (e) => {const code = e.detail && e.detail.code;const input = document.getElementById('identcode');if (!input || !code || handed.has(code)) return; // a one-time code is exchanged oncehanded.add(code);input.value = code;input.dispatchEvent(new Event('change', { bubbles: true }));});// "Log in with ident": return to this page (the server accepts only a same-origin path)const withNext = (a) => {try {const u = new URL(a.href);const ret = new URL(u.searchParams.get('return'));const here = location.pathname + location.search;ret.search = '';if (here !== '/' && here.length <= 500) ret.searchParams.set('next', here);u.searchParams.set('return', ret.href);a.href = u.href;} catch (err) { /* keep the server's href: the login still works, it returns to / */ }};const onButton = (e) => {const a = e.target && e.target.closest && e.target.closest('#loginbutton');if (a) withNext(a);};for (const t of ['click', 'auxclick', 'contextmenu']) document.addEventListener(t, onButton, true);window.__ticketsLogin = { sync };})();
Branches
Latest commits
- 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
- 22751914sync components.hybriel 8d79ff7: bubble hugs its content, quiet 'edited' label; gate checksmre
- c8452453sync components 9a: shared Icon (icons/icons.hl), md-editor toolbar icons + single focus ring (components f4-icons ba96735)mre
- 52ba11e8sync-components: copy icons/icons.hl + README (F4); testsmre
- 138d198dmd-editor.hl: verbatim copy of components f3-mdvalue (an older text handed back is kept)mre
- 18d2df60md-editor.hl: verbatim copy of components f3-mdvalue (an outside value change is shown by the editor)mre
- f6764bedreports/H1-hydrate.mdmre
- 1bbbf0edtests/browser.mjs: wait for hydration before clicking the login button on / (device B)mre
- 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