fix(platform): prevent false access-denied screens during auth token refreshes#508
Conversation
…refreshes Skip member context queries while auth is loading or unauthenticated to avoid the backend returning null during token refreshes. Preserve the last known role in the dashboard layout so navigation items don't flicker.
Greptile SummaryThis PR prevents false "Access denied" screens during auth token refreshes by skipping Key changes:
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| services/platform/app/hooks/use-current-member-context.ts | Added skip parameter with detailed documentation explaining the auth loading pattern |
| services/platform/app/routes/dashboard/$id.tsx | Implemented useRef to preserve role during auth refreshes, preventing nav flicker |
| services/platform/app/routes/dashboard/$id/_knowledge.tsx | Applied skip pattern for auth loading and added isAuthLoading check |
| services/platform/app/routes/dashboard/$id/settings.tsx | Applied skip pattern and added isAuthLoading to loading condition |
| services/platform/app/routes/dashboard/$id/settings/teams.tsx | Applied skip pattern and added isAuthLoading to loading condition |
Last reviewed commit: d401d94
📝 WalkthroughWalkthroughThis pull request introduces authentication-aware loading guards across the dashboard application. It adds documentation to Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@services/platform/app/routes/dashboard/`$id/automations/$amId.tsx:
- Around line 166-171: The current loading guard sets isLoading =
isLoadingAutomation || isLoadingSteps but omits isAuthLoading, causing
memberContext to be briefly undefined and default role to 'Member'; update the
loading logic (where isLoading is computed) to include isAuthLoading (and/or
!isAuthenticated) so isLoading = isAuthLoading || !isAuthenticated ||
isLoadingAutomation || isLoadingSteps, or alternatively implement a last-known
role preservation around memberContext so AutomationNavigation uses the previous
memberContext.role until auth finishes; make the change near the
useConvexAuth/useCurrentMemberContext and isLoading variable declarations.
Summary
useCurrentMemberContextqueries while auth is loading or the user is unauthenticated, preventing the backend from returningnullduring token refreshes and causing false "Access denied" screensuseRefin the dashboard layout so navigation items don't flicker during reconnectionsskip = isAuthLoading || !isAuthenticatedpattern consistently across all 13 dashboard routes that useuseCurrentMemberContextTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Bug Fixes
Improvements