fix(auth): gate AuthGuard onboarding redirect on /me reconcile (MAPPS-317) #362
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
psa-systems/mokosh-apps!362
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/MAPPS-317-calendar-bounce-router-guard"
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?
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