-
Notifications
You must be signed in to change notification settings - Fork 0
feat(auth): improve token refresh on optional routes for better ux #211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Always attempt token refresh on optional auth routes (e.g., /meetings/) - Implement graceful failure handling based on route type - Optional routes: log warning and continue without token (no logout) - Required routes: log error and force logout for re-authentication - Replace attemptRefresh parameter with isOptionalRoute for clearer intent - Simplify auth decision logic by removing redundant checks Benefits: - Authenticated users get enhanced features when possible - No interruption to meeting access if refresh fails - Better logging differentiation (WARNING vs ERROR) - No redirect loops on optional routes - Maintains backward compatibility LFXV2-913 Generated with [Claude Code](https://claude.ai/code) Signed-off-by: Asitha de Silva <[email protected]>
WalkthroughToken extraction logic in authentication middleware is refactored to always attempt token refresh when expired, with refined failure behavior based on route type: optional routes log warnings and continue without tokens, while required routes trigger re-authentication. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (4)**/*.{ts,tsx,js,jsx,css,scss}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
apps/lfx-one/src/**/*.ts📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧬 Code graph analysis (1)apps/lfx-one/src/server/middleware/auth.middleware.ts (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (5)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances the authentication middleware to improve user experience by always attempting token refresh on optional authentication routes (like /meetings/), while maintaining different failure handling based on route type. The change enables authenticated users on optional routes to access enhanced features when token refresh succeeds, without disrupting access when it fails.
Key Changes
- Modified token refresh behavior to always attempt refresh regardless of route type, improving UX for authenticated users on optional routes
- Implemented differentiated error handling: optional routes log warnings and continue without forced logout, while required routes log errors and force re-authentication
- Simplified authentication decision logic by removing redundant checks, since
needsLogoutis now always false for optional routes
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Updated auth middleware to always attempt token refresh on optional authentication routes (like
/meetings/), providing better UX for authenticated users while maintaining safe fallback behavior.Changes Made
extractBearerTokento always attempt token refresh regardless of route typeisOptionalRouteparameter instead ofattemptRefreshBenefits
Technical Details
apps/lfx-one/src/server/middleware/auth.middleware.tsJIRA
LFXV2-913
Generated with Claude Code