fix(invitations): preserve tokens after error in invitation flow#2806
Merged
waleedlatif1 merged 1 commit intostagingfrom Jan 14, 2026
Merged
fix(invitations): preserve tokens after error in invitation flow#2806waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1 merged 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile SummaryThis PR fixes a critical bug in the workspace invitation flow where tokens were lost during error scenarios. Previously, when users encountered errors (expired invitation, email mismatch, etc.), the token was not preserved in the redirect URL, causing the frontend to fall back to using the invitation ID as the token. This complicated the flow significantly when users needed to switch accounts. The fix ensures that:
The implementation includes comprehensive test coverage for all error paths, URL encoding edge cases, and end-to-end flow validation. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Browser
participant InvitePage as /invite/[id]
participant API as /api/invitations/[id]
participant SessionStorage
Note over User,SessionStorage: Scenario: Email Mismatch with Token Preservation
User->>Browser: Click invitation link with token param
Browser->>InvitePage: Load page with token in query
InvitePage->>SessionStorage: Store invitation token
InvitePage->>API: GET with token param
Note over API: User logged in with wrongEmail
Note over API: Invitation sent to correctEmail
API->>API: Detect email mismatch
API->>Browser: Redirect with error and token preserved
Browser->>InvitePage: Load error page with token
InvitePage->>SessionStorage: Token already stored
InvitePage->>User: Show "Wrong Account" error
User->>InvitePage: Click "Sign in with different account"
InvitePage->>SessionStorage: Read stored token
InvitePage->>Browser: Redirect to login with callback
Note over User,Browser: User signs in with correctEmail
Browser->>InvitePage: Return with token in URL
InvitePage->>SessionStorage: Token persists
InvitePage->>API: GET with token param
Note over API: User now logged in with correctEmail
API->>API: Email matches successfully
API->>API: Accept invitation
API->>Browser: Redirect to workspace
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Type of Change
Testing
Tested manually, added tests
Checklist