oidc.py: single-sourced shared module; guest pill consumes the portal's state

- app/oidc.py is now a byte-identical copy of the canonical module
  (ops-docs: scripts/shared/oidc_client.py); this app's identity (logger
  name, session cookie, session salt) is set via oidc.configure() in
  main.py with the app's historical values, so existing sessions survive.
  tests/test_oidc_sync.py pins the copy to the canonical revision.
- Guests list: the pill CONSUMES the portal-served `state` (the single
  invited-vs-active derivation now lives in the portal and is tested
  there). The local active-flag re-derivation is deleted — the shim is
  first-served-field-wins (state → guest_status), so the previous payload
  shape renders identically during a portal rollback. Guests harness
  extended: invited-wins-over-ledger-active, served expired, and a
  payload with neither field renders NO derived pill text.
This commit is contained in:
inference-bot committed 2026-11-11 05:23:05 +00:00
1 parent 267a573eda
commit 80acfaed3b
4 files changed
+160 -16

No files matched your search

+16 -4
View File
@@ -25,6 +25,13 @@ from fastapi.responses import HTMLResponse, JSONResponse, RedirectResponse
from app import oidc
# The oidc module is SHARED (byte-identical copy of the canonical
# ops-docs: scripts/shared/oidc_client.py — see tests/test_oidc_sync.py);
# this app's identity (logger name, session cookie, session salt) is set
# here. The cookie name and salt are the app's historical values, so
# existing sessions survive the consolidation.
oidc.configure("admin-panel", "admin_oidc_session", "admin-panel-oidc-session")
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("admin-panel")
@@ -1347,11 +1354,16 @@ function renderMembers() {
const emailLine = g.username ? '<div style="color:var(--muted);font-size:11px">' + esc(g.email) + '</div>' : '';
const credits = Number(g.credits_remaining ?? g.credit_balance ?? 0);
const exp = g.guest_expires_at ? String(g.guest_expires_at).slice(0, 10) : '—';
// The portal derives the display state: 'invited' while the guest has
// not accepted their setup invite (provisioned but cannot log in yet —
// never 'active' before that), else the ledger status.
// The portal derives the display state — the SINGLE derivation, tested
// once in the portal (tests/test_guest_invited_state.py): 'invited'
// while the guest has not accepted their setup invite, else the
// guests-ledger status. This row is a pure consumer: first served field
// wins, nothing is derived here from flags. (guest_status first keeps
// the previous payload shape rendering identically during a portal
// rollback; a payload with neither field renders an empty pill — that
// shape no longer exists and must not be re-derived.)
const st = g.state === 'invited' ? 'invited'
: String(g.guest_status || (g.active ? 'active' : 'inactive'));
: String(g.guest_status || g.state || '');
const stClass = { invited: 'invited', active: 'active', converted: 'org' }[st] || 'inactive';
const stTitle = {
invited: 'Invited — awaiting setup (the guest has not accepted their invite yet)',