fix: preserve session on transient auth checks#82
Conversation
🚀 PR Received SuccessfullyHello @saurabhhhcodes, Thank you for taking the initiative to contribute to this project. Please ensure that your PR follows all project guidelines properly before requesting review.
|
|
Warning Review limit reached
More reviews will be available in 37 minutes and 45 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAuthContext now tracks an ChangesAuth Error Tracking and Selective Redirect Gating
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Quick follow-up: this PR is still clean and mergeable from my side. If there is no further feedback needed here, please review and merge when convenient; I can respond quickly if you want any changes. |
…transient-auth-39 # Conflicts: # frontend/src/context/AuthContext.jsx # frontend/src/services/api.js
|
@saurabhhhcodes is attempting to deploy a commit to the Kunal Verma's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Refreshed this PR against current main and resolved the auth-context/api conflicts. Resolution notes:
Validation:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/context/AuthContext.jsx`:
- Around line 31-45: The initAuth bootstrap treats any non-401/403 getMe()
failure as signed-out by leaving user null and clearing loading; change it to
preserve the last known authenticated state (or introduce an explicit
"authUnknown" flag) instead of setting user to null on transient errors: in
initAuth, on catch for non-401/403 errors do not overwrite setUser (leave
existing user value) and set a separate state like setAuthError(...) or
setAuthUnknown(true) so that callers relying on !loading && !isAuthenticated
don't treat temporary failures as sign-out; keep handling for 401/403 to clear
user via setUser(null) and still call setLoading(false) when finished.
In `@frontend/src/services/api.js`:
- Around line 25-29: The current substring check using requestUrl.includes(path)
causes false positives; instead parse the requestUrl into a URL object (e.g. new
URL(requestUrl, window.location.origin)), normalize its pathname (remove
trailing slash if needed) and then check AUTH_ONLY_PATHS.some(path =>
normalizedPathname === path) so only exact pathname matches trigger the
redirect; update the logic around AUTH_FAILURE_STATUSES, AUTH_ONLY_PATHS and the
isAuthPath computation to use the URL pathname and handle relative URLs safely.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6637730e-6898-48b9-82a3-68e43f19d848
📒 Files selected for processing (2)
frontend/src/context/AuthContext.jsxfrontend/src/services/api.js
Fixes #39.
What changed
401or403).401/403as auth failures while leaving other failures to callers.Validation
cd frontend && ./node_modules/.bin/eslint src/context/AuthContext.jsx src/services/api.jsgit diff --checkNote:
cd frontend && ./node_modules/.bin/vite buildis blocked locally by the installed Rolldown native binding failing macOS code-signing/native optional dependency loading, before app code compiles.Suggested labels for GSSoC:
gssoc:approved,level:intermediate,quality:clean,type:bug.Summary by CodeRabbit
New Features
Bug Fixes