feat(GRO-2359): add POST /api/portal/clients-from-auth for OOBE #212
Reference in New Issue
Block a user
Delete Branch "feature/2357-p2-portal-clients-from-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?
GRO-2359 — companion API change for the OOBE portal-creation flow
The OOBE component (web
src/portal/OOBE.tsx) callsPOST /api/portal/clients-from-authto create a freshclientsrow bound to the Better Auth user's email. This PR adds that endpoint.Contract
POST /api/portal/clients-from-authauth.api.getSession({ headers })— registered BEFORE thevalidatePortalSessionmiddleware, same pattern as the existingPOST /session-from-auth){ name: string; phone?: string|null; address?: string|null; notes?: string|null }(zod-validated){ id, name, email }clientsrow already exists for this email (portal-selection case)What changed
src/routes/portal.ts— newPOST /clients-from-authhandler (registered before thevalidatePortalSessionmiddleware, alongsidesession-from-auth).src/__tests__/portalClientsFromAuth.test.ts— 7 new tests covering 401, 400, 201 (with persisted values, name trim, optional-field normalisation to null), 409 (existing client), 409 (unique-constraint race via 23505), 503.Pairing
Companion to the web PR on
groombook/webbranchfeature/2357-p2-sso-to-oobe-routing(PR #75). The web PR is the user-facing fix; this API PR is the necessary backend addition. Both ship in the same release per GRO-2357.SDLC path
feature/2357-p2-portal-clients-from-auth→dev→uat→main. Tests pass locally (pnpm vitest run src/__tests__/portalClientsFromAuth.test.ts= 7/7 ✅).