fix(portal): wire dev client login to portal session #184

Merged
groombook-engineer[bot] merged 4 commits from fix/gro-300-dev-client-portal-auth into main 2026-03-30 18:25:01 +00:00

4 Commits

Author SHA1 Message Date
Barkley Trimsworth 4fb0c7b14d fix(api): use valid staff ID for dev-session impersonation
The hardcoded DEV_STAFF_ID (all zeros) did not exist in the staff
table, causing a foreign-key violation and 500 error. Now falls back
to the demo-manager (KNOWN_STAFF_ID from seed) or any active staff
record instead.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-30 18:09:09 +00:00
Barkley Trimsworth 08e2f8c1ab fix(web): add missing PWA icon and favicon assets
Adds pwa-192x192.png, pwa-512x512.png, and favicon.svg to the web
public directory. These are referenced by the VitePWA plugin manifest
and were causing 404 errors on every page load.

cc @cpfarhood

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-30 17:10:58 +00:00
Barkley Trimsworth 51431c7bc1 fix(portal): wire dev client login to portal session
When a client user selects their account from the dev login selector,
the portal previously had no way to establish an authenticated session —
it only checked for a ?sessionId= URL param (used by the real staff
impersonation flow). This caused the portal to always show "Hi, Guest".

Changes:
- POST /api/portal/dev-session: new endpoint (auth-disabled only) that
  creates an impersonation session for a given clientId, using a fixed
  dev staff ID to avoid conflicts with the one-active-session-per-staff
  rule in the real impersonation flow. Sessions are long-lived (24h).
- CustomerPortal: on mount, after checking for ?sessionId=, also check
  for a dev client user in localStorage and call /api/portal/dev-session
  to obtain a session. This mirrors the real impersonation flow so all
  existing portal API calls (which require X-Impersonation-Session-Id)
  work without modification.

cc @cpfarhood

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-30 17:07:49 +00:00
Barkley Trimsworth 853c55fd04 fix(staff): count only active super users in last-super-user guardrail
Add active=true filter to all 3 superUserCount queries in staff.ts
(revoke, deactivate, delete) so inactive super users aren't counted,
preventing false positives when checking the last-super-user guardrail.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-30 14:50:50 +00:00