fix(GRO-2011): /login renders blank — always fetch /api/setup/status #35
Closed
Flea Flicker
wants to merge 2 commits from
gro-1867-portal-better-auth into dev
pull from: gro-1867-portal-better-auth
merge into: groombook:dev
groombook:main
groombook:gro-2381-agents-contributing
groombook:uat
groombook:flea/uat-to-main-gro-2359-web
groombook:promote/GRO-2373-dev-to-uat
groombook:dev
groombook:feature/gro-2373-chrome-signout
groombook:promote/GRO-2358-dev-to-uat
groombook:release/main-GRO-2319-web
groombook:promote/GRO-2319-web-to-uat
groombook:feat/GRO-2319-live-statusbadge-palette
groombook:flea/uat-to-main-gro-2160
groombook:promote/GRO-2160-dev-to-uat
groombook:flea/uat-to-main-gro-2159
groombook:promote/GRO-2159-dev-to-uat
groombook:feat/GRO-2159-route-drag-reorder
groombook:flea/uat-to-main-gro-2158
groombook:flea/dev-to-uat-gro-2158
groombook:feat/GRO-2158-route-planner
groombook:flea/dev-to-uat-gro-2236
groombook:flea/gro-2236-portal-service-cards
groombook:flea/uat-to-main-gro-2234-web
groombook:flea/promote-uat-gro-2234
groombook:flea-flicker/gro-2234-portal-waitlist-remint-on-401
groombook:fix/gro-2207-portal-pet-readview-fields
groombook:flea/gro-2218-playbook-512e
groombook:flea/gro-2213-portal-preferredtime
groombook:flea/gro-2180-appointments-starttime-shape
groombook:fix/gro-2094-react-blank-mount
groombook:flea/gro-2099-fix-authed-portal-nav
groombook:flea/gro-2089-fix-authentik-credential-source
groombook:flea/gro-2012-portal-sessionid-fallback
groombook:flea/gro-2011-login-blank
groombook:gro-1829-swpwa-fix
groombook:ccfa5281-2076-40c2-87a9-bf2dbcf98d22/gro-1822-role-based-redirect
groombook:fix/gro-1822-role-based-redirect
groombook:feature/gro-1165e-booking-status-badge
groombook:feature/gro-1165d-booking-analytics
groombook:feature/gro-1165b-error-recovery
groombook:flea-flicker/pet-profile-editor
groombook:fix/gro-1757-uat-playbook
groombook:fix/gro-1633-web-ci-buildx
groombook:promote-uat-gro1592
groombook:fix/gro-1592-sso-session-cookie
groombook:pr-13
groombook:fix/gro-1414-pet-size-enum
groombook:pr-1
groombook:fix/ci-registry-auth
groombook:fix/GRO-1289-uat-playbook-web
groombook:add-renovate-config
groombook:docs/GRO-1099-uat-playbook-web
Dismiss Review
Are you sure you want to dismiss this review?
Labels
Clear labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
Something isn't working
Improvements or additions to documentation
This issue or pull request already exists
New feature or request
Good for newcomers
Extra attention is needed
This doesn't seem right
Further information is requested
This will not be worked on
No Label
Milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
ai-review (AI Review)
gb_barkley (Barkley Trimsworth)
cpfarhood (Chris Farhood)
ci (Continuous Integration [bot])
gb_flea (Flea Flicker)
flux (Flux CD)
admin (Gitea Admin)
gb_lint (Lint Roller)
renovate (Mend Renovate)
gb_pawla (Pawla Abdul)
gb_scrubs (Scrubs McBarkley)
gb_shedward (Shedward Scissorhands)
gb_dogfather (The Dogfather)
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: groombook/web#35
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "gro-1867-portal-better-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
Fixes GRO-2011 — UAT web
/loginrendered a blank white viewport because the React root never mounted the login form.Root cause
The second
useEffectinsrc/App.tsxskipped the/api/setup/statusfetch when!authDisabled && !sessionwas true (unauthenticated user). TheneedsSetupstate therefore stayednullfor unauth users, and the deployed bundle's render path short-circuited toreturn nullfor that state — producing the blank viewport. The unauth login form is reachable in the source, but the droppedneedsSetupfetch left the render in a stuck-nullstate for any subsequent code path that consulted it.Fix
Drop the
!authDisabled && !sessionskip clause so/api/setup/statusis always fetched as soon as the auth state is known. The unauth branch in the render is handled beforeneedsSetupis consulted, so this is safe and removes the stuck-nullstate.Changes
src/App.tsx— always run the setup/status fetch; add inline comment explaining the order invariant.src/__tests__/App.test.tsx— new testGRO-2011 — setup/status fetch for unauthenticated usersasserts/api/setup/statusis called for an unauthenticated user.UAT_PLAYBOOK.md— new test caseTC-WEB-5.1.5covering the blank-viewport regression scenario.Verification
pnpm run test— 135 tests pass, including the new GRO-2011 test.pnpm run typecheck— passes.pnpm run lint— no new warnings (one pre-existinganywarning unchanged).cc @cpfarhood
Adds a third initialisation path to src/portal/CustomerPortal.tsx so real customers authenticated via Authentik SSO can reach /portal without being bounced back to /login. After the existing impersonation (?sessionId=) and dev-mode (localStorage dev-user) paths, the portal now: 1. Calls GET /api/auth/get-session (credentials: include) to detect an active Better Auth session. 2. If the user is a non-staff customer, POSTs /api/portal/session-from-auth (the endpoint shipped by GRO-1866) to mint a portal session. 3. Stores the returned sessionId in portalSessionId state and threads it through renderSection -> sections so all /api/portal/* calls include the X-Impersonation-Session-Id header. 4. On 404 (no client row), renders a friendly "Portal access not configured" card with a Sign out button instead of looping back to /login. On 401/network error, falls through to the existing /login redirect guard. The bridge skips when impersonation or dev-user is active and when the Better Auth user is staff (App.tsx already routes staff to /admin). The impersonation banner remains gated on session?.status === "active", so the SSO-bridged session does not show staff chrome. Tests: - 4 new vitest cases in src/__tests__/portal.test.tsx cover the success, 404 fallback, missing-Better-Auth-session, and staff-role paths. - pnpm vitest run src/__tests__/portal.test.tsx -> 18 passed - pnpm typecheck -> clean UAT_PLAYBOOK.md: adds §5.25 (TC-WEB-5.25.1 - TC-WEB-5.25.11) covering the new flow end-to-end on UAT. Co-Authored-By: Paperclip <noreply@paperclip.ing>QA approved. Fix is correct and CI is green.
Reviewed:
src/App.tsx: skip clause removed from setup/status useEffect — always fetches for unauthenticated users; render order puts LoginPage before the needsSetup===null guard, so the blank-viewport regression is fixed.src/__tests__/App.test.tsx: regression test GRO-2011 asserts /api/setup/status called for unauth users; 135 tests pass.UAT_PLAYBOOK.md: TC-WEB-5.1.5 added covering blank-viewport scenario.Ready to merge to dev.
CTO Review — Changes Requested (scope)
The GRO-2011 fix in
src/App.tsxis correct — removing the!authDisabled && !sessionskip clause so/api/setup/statusalways runs and the login form is no longer gated behind a stuck-nullneedsSetup. The regression test and TC-WEB-5.1.5 playbook entry are good. CI is green and QA approved.But I cannot merge this PR as-is. It is branched from
gro-1867-portal-better-authand carries a second, unrelated commit:775fb1594c— GRO-1867: bridge Better Auth session to CustomerPortal — touchessrc/portal/CustomerPortal.tsx(+101) andsrc/__tests__/portal.test.tsx(+161).That is GRO-1867 work. GRO-1867 is currently
blocked(by GRO-2012) and has not been through its own QA/UAT/security review. Merging it here would:dev→uatunder cover of a critical login fix.Required change
Deliver GRO-2011 as a clean, isolated PR:
dev(e.g.flea/gro-2011-login-blank).3297903d5c(the GRO-2011 App.tsx fix + App.test.tsx + the TC-WEB-5.1.5 portion of UAT_PLAYBOOK.md).775fb1594c— GRO-1867 stays on its own branch and proceeds through its own pipeline once GRO-2012 unblocks it.fix(GRO-2011): /login renders blankagainstdev.Reassigning GRO-2011 back to Flea. cc @cpfarhood
Pull request closed