fix: add server-side redirect for users with pending invites on onboarding page#2
Conversation
…rding page When users sign up with an invite token, they were being redirected to /onboarding/getting-started (plan selection page) instead of going directly to /onboarding/personal/settings. This caused users to see the payment prompt for team/org plans before being redirected. This fix adds a server-side check in the /onboarding/getting-started page to redirect users with pending invites directly to the personal onboarding flow, preventing them from seeing the plan selection page. Also refactored onboardingUtils.ts to use MembershipRepository instead of direct prisma access. Co-Authored-By: sean@cal.com <Sean@brydon.io>
Co-Authored-By: sean@cal.com <Sean@brydon.io>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9710b2235b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const pendingInvite = await prisma.membership.findFirst({ | ||
| where: { | ||
| userId, | ||
| accepted: true, | ||
| }, |
There was a problem hiding this comment.
Use accepted=false in pending-invite lookup
The new hasPendingInviteByUserId query filters with accepted: true, which matches accepted memberships rather than pending invites. This inverts the meaning of the check: users who already accepted a team will be treated as having a “pending invite,” while users with actual pending invites (accepted: false) will return false. In flows like the onboarding redirect that rely on this method, accepted users will be sent to /onboarding/personal/settings and pending-invite users won’t get the intended redirect.
Useful? React with 👍 / 👎.
| if (hasPendingInvite || onboardingV3Enabled) { | ||
| return "/onboarding/personal/settings"; |
There was a problem hiding this comment.
Avoid routing all v3 users to personal settings
The condition hasPendingInvite || onboardingV3Enabled now returns /onboarding/personal/settings for every user when the onboarding-v3 flag is enabled, even if they have no pending invite. That makes the standard v3 entry point (/onboarding/getting-started) unreachable and skips the plan-selection step for non-invited users. This is inconsistent with other v3 routing helpers like OnboardingPathService.getGettingStartedPath (which uses /onboarding/getting-started for v3 and reserves personal settings for invited flows). Users with v3 enabled but no pending invite will be redirected to the wrong step.
Useful? React with 👍 / 👎.
Benchmark PR from agentic-review-benchmarks#2