Fix OAuth redirection handling in invite flow#516
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ChangesInvite Validation Redirect Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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
`@packages/react/src/components/presentation/auth/AcceptInvite/v2/BaseAcceptInvite.tsx`:
- Around line 637-644: The REDIRECTION branch in BaseAcceptInvite.tsx currently
falls through when response.type === 'REDIRECTION' but redirectURL is missing;
update the handler for response.type === 'REDIRECTION' to treat a missing/empty
redirectURL as an error: detect redirectURL (from response.data?.redirectURL ||
(response as any)?.redirectURL), and if falsy, log or set an error state and
return early instead of continuing, otherwise call
initiateOAuthRedirect(redirectURL) as before; ensure you reference the same
symbols (response.type, redirectURL, initiateOAuthRedirect) and exit the
function after handling the error case to avoid leaving the UI in a dead-end
state.
🪄 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: 5ec60faa-0082-425d-9ec0-782737953e2d
📒 Files selected for processing (1)
packages/react/src/components/presentation/auth/AcceptInvite/v2/BaseAcceptInvite.tsx
| if (response.type === 'REDIRECTION') { | ||
| const redirectURL: any = response.data?.redirectURL || (response as any)?.redirectURL; | ||
|
|
||
| if (redirectURL && typeof window !== 'undefined') { | ||
| initiateOAuthRedirect(redirectURL); | ||
| return; | ||
| } | ||
| } |
There was a problem hiding this comment.
Fail fast when REDIRECTION is returned without a usable URL.
At Line 637, if response.type is REDIRECTION but redirectURL is missing/empty, execution falls through and may lead to a dead-end UI. Treat this as an error and return early.
Suggested patch
if (response.type === 'REDIRECTION') {
const redirectURL: any = response.data?.redirectURL || (response as any)?.redirectURL;
if (redirectURL && typeof window !== 'undefined') {
initiateOAuthRedirect(redirectURL);
return;
}
+
+ setIsTokenInvalid(true);
+ handleError(new Error('Invalid redirection response: missing redirect URL.'));
+ return;
}🤖 Prompt for 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.
In
`@packages/react/src/components/presentation/auth/AcceptInvite/v2/BaseAcceptInvite.tsx`
around lines 637 - 644, The REDIRECTION branch in BaseAcceptInvite.tsx currently
falls through when response.type === 'REDIRECTION' but redirectURL is missing;
update the handler for response.type === 'REDIRECTION' to treat a missing/empty
redirectURL as an error: detect redirectURL (from response.data?.redirectURL ||
(response as any)?.redirectURL), and if falsy, log or set an error state and
return early instead of continuing, otherwise call
initiateOAuthRedirect(redirectURL) as before; ensure you reference the same
symbols (response.type, redirectURL, initiateOAuthRedirect) and exit the
function after handling the error case to avoid leaving the UI in a dead-end
state.
🦋 Changeset detectedThe changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. |
Purpose
This pull request introduces a conditional OAuth redirection flow in the
BaseAcceptInvitecomponent. Now, if the server response indicates a redirection type, the component will automatically initiate an OAuth redirect using the provided URL.Related Issues
Related PRs
Checklist
Security checks
Summary by CodeRabbit