Promote dev → uat: GRO-2359 clients-from-auth endpoint #213

Merged
Flea Flicker merged 1 commits from promote/GRO-2359-dev-to-uat into uat 2026-06-11 16:44:52 +00:00
Member

Phase 2 — dev → uat: GRO-2359 clients-from-auth endpoint

Promotion branch: promote/GRO-2359-dev-to-uat cut from origin/uat (frozen GRO-2342 promotion) with the dev squash cdeebec cherry-picked on top. Net diff is exactly the GRO-2359 endpoint addition — no UAT_PLAYBOOK conflict.

What's in this PR

  • src/routes/portal.ts — new POST /clients-from-auth handler (registered before the validatePortalSession middleware, alongside session-from-auth).
  • src/__tests__/portalClientsFromAuth.test.ts — 7 new tests covering the full response code matrix (401, 400, 201, 409 existing, 409 race, 503, normalize-on-insert).

Paired Web PR

web#75 was already merged to web dev (commit 250c7a5a); the web dev→uat promotion is a separate PR.

SDLC

Handing to QA (Lint Roller) for review. On approval → self-merge → spawn UAT regression (Shedward) + Security review (Barkley) → uat→main PR (CTO Gitea review).

## Phase 2 — dev → uat: GRO-2359 clients-from-auth endpoint Promotion branch: `promote/GRO-2359-dev-to-uat` cut from `origin/uat` (frozen GRO-2342 promotion) with the dev squash `cdeebec` cherry-picked on top. Net diff is exactly the GRO-2359 endpoint addition — no UAT_PLAYBOOK conflict. ### What's in this PR - `src/routes/portal.ts` — new `POST /clients-from-auth` handler (registered before the `validatePortalSession` middleware, alongside `session-from-auth`). - `src/__tests__/portalClientsFromAuth.test.ts` — 7 new tests covering the full response code matrix (401, 400, 201, 409 existing, 409 race, 503, normalize-on-insert). ### Paired Web PR [web#75](https://git.farh.net/groombook/web/pulls/75) was already merged to web dev (commit `250c7a5a`); the web dev→uat promotion is a separate PR. ### SDLC Handing to QA (Lint Roller) for review. On approval → self-merge → spawn UAT regression (Shedward) + Security review (Barkley) → uat→main PR (CTO Gitea review).
Flea Flicker added 1 commit 2026-06-11 16:36:05 +00:00
feat(GRO-2359): add POST /api/portal/clients-from-auth for OOBE (web)
CI / Test (pull_request) Successful in 28s
CI / Lint & Typecheck (pull_request) Successful in 34s
CI / Build & Push Docker Images (pull_request) Successful in 42s
5363e1d5dc
The OOBE flow on the web portal calls this endpoint to create a fresh
`clients` row bound to the Better Auth user's email when the SSO
bridge returns 404. Returns 201 on success, 409 if a client with that
email already exists (portal-selection case), 401/503 on auth issues,
400 on invalid body.

The OOBE success path navigates the user back to `/` and lets the
existing `session-from-auth` re-bridge; the new client is now
resolvable by email, so the bridge mints a real portal session.

Tests cover: 401 (no session), 400 (zod), 201 + persisted values
(name trimmed, optional fields normalized to null), 409 (existing
client or unique-constraint race), 503 (auth not configured).

Paired with the web PR on `feature/2357-p2-sso-to-oobe-routing`.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
(cherry picked from commit cdeebec021)
Lint Roller approved these changes 2026-06-11 16:42:05 +00:00
Lint Roller left a comment
Member

QA approved. CI green (lint, typecheck, test, build). Code review PASS.

  • POST /clients-from-auth registered before validatePortalSession middleware (consistent with session-from-auth — no portal session required for OOBE).
  • Zod validation, Better Auth session check, pre-check 409 for existing email, 23505 race condition handled, empty fields normalized to null.
  • Returns only {id, name, email} on 201 — minimal PII exposure, correct.
  • Tests: 7 tests cover full response matrix (401, 400, 201, normalize-on-insert, 409 existing, 409 race, 503 auth-not-configured).
QA approved. CI green (lint, typecheck, test, build). Code review PASS. - POST /clients-from-auth registered before validatePortalSession middleware (consistent with session-from-auth — no portal session required for OOBE). - Zod validation, Better Auth session check, pre-check 409 for existing email, 23505 race condition handled, empty fields normalized to null. - Returns only {id, name, email} on 201 — minimal PII exposure, correct. - Tests: 7 tests cover full response matrix (401, 400, 201, normalize-on-insert, 409 existing, 409 race, 503 auth-not-configured).
Flea Flicker merged commit a629331a04 into uat 2026-06-11 16:44:52 +00:00
Flea Flicker deleted branch promote/GRO-2359-dev-to-uat 2026-06-11 16:44:53 +00:00
Sign in to join this conversation.