fix(auth): gate AuthGuard onboarding redirect on /me reconcile (MAPPS-317) #362

Merged
YousifShkara merged 1 commit from fix/MAPPS-317-calendar-bounce-router-guard into main 2026-06-26 06:37:34 +02:00
Owner

Clicking 'Calendar' (and other sidebar items) reliably bounced to /dashboard on the first in-app navigation. Trace of the race: the optimistic rehydrate from sessionStorage sets profile_completed=true so the AuthGuard renders Outlet -> CalendarPage; a subsequent /me reconcile (or token-refresh /me) flipped profile_completed to false momentarily, AuthGuard's render-time check fired nav.replace(/onboarding/profile), Onboarding mounted, its defense-in-depth use_effect saw the next signal tick with profile_completed=true, and nav.replace(Dashboard) landed the user on /dashboard. Full page loads of /calendar never hit the race because /me had already settled by first paint.

Fix: add AuthContext.server_loaded (false until refresh_user_from_me sets it true) and gate both the AuthGuard's onboarding redirect and Onboarding's dashboard bounce-back on the flag. Until /me confirms, neither guard fires, so transient stale auth states cannot start the chain. Also adds tracing breadcrumbs at both redirect sites so the next reproduction (if any) shows the fire reason in console logs.

#MAPPS-317

Clicking 'Calendar' (and other sidebar items) reliably bounced to /dashboard on the first in-app navigation. Trace of the race: the optimistic rehydrate from sessionStorage sets profile_completed=true so the AuthGuard renders Outlet -> CalendarPage; a subsequent /me reconcile (or token-refresh /me) flipped profile_completed to false momentarily, AuthGuard's render-time check fired nav.replace(/onboarding/profile), Onboarding mounted, its defense-in-depth use_effect saw the next signal tick with profile_completed=true, and nav.replace(Dashboard) landed the user on /dashboard. Full page loads of /calendar never hit the race because /me had already settled by first paint. Fix: add AuthContext.server_loaded (false until refresh_user_from_me sets it true) and gate both the AuthGuard's onboarding redirect and Onboarding's dashboard bounce-back on the flag. Until /me confirms, neither guard fires, so transient stale auth states cannot start the chain. Also adds tracing breadcrumbs at both redirect sites so the next reproduction (if any) shows the fire reason in console logs. #MAPPS-317
fix(auth): gate AuthGuard onboarding redirect on /me reconcile (MAPPS-317)
All checks were successful
Check / fmt + clippy + tests (pull_request) Successful in 13m23s
Create release / Create release from merged PR (pull_request) Has been skipped
4c4cd3d6bc
Clicking 'Calendar' (and other sidebar items) reliably bounced to /dashboard on the first in-app navigation. Trace of the race: the optimistic rehydrate from sessionStorage sets profile_completed=true so the AuthGuard renders Outlet -> CalendarPage; a subsequent /me reconcile (or token-refresh /me) flipped profile_completed to false momentarily, AuthGuard's render-time check fired nav.replace(/onboarding/profile), Onboarding mounted, its defense-in-depth use_effect saw the next signal tick with profile_completed=true, and nav.replace(Dashboard) landed the user on /dashboard. Full page loads of /calendar never hit the race because /me had already settled by first paint.

Fix: add AuthContext.server_loaded (false until refresh_user_from_me sets it true) and gate both the AuthGuard's onboarding redirect and Onboarding's dashboard bounce-back on the flag. Until /me confirms, neither guard fires, so transient stale auth states cannot start the chain. Also adds tracing breadcrumbs at both redirect sites so the next reproduction (if any) shows the fire reason in console logs.

#MAPPS-317
YousifShkara deleted branch fix/MAPPS-317-calendar-bounce-router-guard 2026-06-26 06:37:34 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!362
No description provided.