fix(portal): wire dev client login to portal session #184
Reference in New Issue
Block a user
Delete Branch "fix/gro-300-dev-client-portal-auth"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
?sessionId=URL param (used by real staff impersonation). This caused the portal to always show "Hi, Guest".POST /api/portal/dev-session(auth-disabled only) that creates an impersonation session for a dev client. UpdatedCustomerPortalto call this endpoint when a dev client user is present in localStorage, mirroring the real impersonation flow.Test plan
groombook.dev.farh.net/login/admin(unaffected)cc @cpfarhood
🤖 Generated with Claude Code
Deployed to groombook-dev
Images:
pr-184URL: https://dev.groombook.farh.net
Ready for UAT validation.
Deployed to groombook-dev
Images:
pr-184URL: https://dev.groombook.farh.net
Ready for UAT validation.
Deployed to groombook-dev
Images:
pr-184URL: https://dev.groombook.farh.net
Ready for UAT validation.
Fix Applied
Updated
POST /api/portal/dev-sessionto use a valid staff ID:DEV_STAFF_ID = "00000000-0000-0000-0000-000000000000"(does not exist)KNOWN_STAFF_ID(demo-manager from seed), falls back to any active staff recordOn the QA diagnosis of
getDevUser()returning null: The code uses key"dev-user"(with hyphen) in localStorage, not"devUser". CheckinglocalStorage.devUseraccesses a different key. The implementation is correct.Please re-test at
groombook.dev.farh.net/login.cc @cpfarhood
Fix Summary
Updated
POST /api/portal/dev-sessionto use a valid staff ID that exists in the database, with fallback logic.Changes:
DEV_STAFF_ID = "00000000-0000-0000-0000-000000000000"which does not existKNOWN_STAFF_ID = "00000000-0000-0000-0000-000000000001"(demo-manager from seed) with fallback to first active staffNote on QA diagnosis: The
localStorage.devUsercheck was accessing the wrong key. The code uses"dev-user"(with hyphen), not"devUser".Ready for re-test.
Deployed to groombook-dev
Images:
pr-184URL: https://dev.groombook.farh.net
Ready for UAT validation.
QA Approval ✓
Tested on:
https://groombook.dev.farh.net(dev environment, post-deploy run 23760158879)Test Steps Completed
/login/)Regression Check
/admin(verified by design — unchanged code path)Files Changed
apps/api/src/routes/portal.ts— newPOST /api/portal/dev-sessionendpoint (auth-disabled only), staff ID fallback fixapps/web/src/portal/CustomerPortal.tsx— calls dev-session on mount when dev client user in localStorageVerdict: Fix verified. Portal now correctly establishes impersonation session for dev clients.
cc @cpfarhood
CTO Approval
Code review passed. Changes are correct, well-scoped, and secure:
POST /api/portal/dev-sessionproperly gated behindAUTH_DISABLED=true— no production exposure00000000-0000-0000-0000-000000000001) with fallback to any active staffShip it.