-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add verification check for PayPal email #2483
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
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes revise PayPal callback error handling by replacing custom errors with generic ones and redirecting unauthorized users to login. They add explicit PayPal email verification checks and append error messages to redirect URLs. The OAuth user info interface is renamed and simplified, with cache expiration extended. The partner auth component now shows toast errors based on URL query parameters. The lead tracking route simplifies Redis cache retrieval by removing fallback to an older key. Changes
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/web/app/(ee)/api/paypal/callback/route.ts (1)
98-101: Consider encoding concerns for error messages in URL.While the error handling approach is good, be mindful that error messages in URL parameters could potentially expose sensitive information or be logged in access logs.
The current implementation uses
encodeURIComponentwhich is correct, but consider if the error messages contain any sensitive information that shouldn't appear in URLs.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/web/app/(ee)/api/paypal/callback/route.ts(4 hunks)apps/web/app/(ee)/partners.dub.co/(dashboard)/auth.tsx(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/web/app/(ee)/api/paypal/callback/route.ts (1)
packages/utils/src/constants/main.ts (1)
PARTNERS_DOMAIN(52-57)
apps/web/app/(ee)/partners.dub.co/(dashboard)/auth.tsx (1)
apps/web/lib/swr/use-partner-profile.ts (1)
usePartnerProfile(6-29)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (10)
apps/web/app/(ee)/api/paypal/callback/route.ts (6)
28-30: LGTM: Improved user experience for unauthenticated users.The change from throwing an error to immediate redirect provides better UX by sending unauthenticated users directly to the login page instead of showing an error.
32-34: Good addition: Local error tracking for URL parameter passing.The introduction of the
errorvariable and try-catch block properly supports the new error handling approach where errors are passed via URL parameters instead of API responses.
49-49: Consistent error handling approach.The change to generic
Errorwith "invalid_state" message aligns with the new error handling strategy.
60-62: Excellent security enhancement: PayPal email verification check.Adding explicit verification of the PayPal email address is a critical security improvement that prevents unverified PayPal accounts from being linked to partner profiles.
90-96: Simplified error handling with proper logging.The new approach logs errors for debugging while capturing the message for user feedback. This is more appropriate for a redirect-based flow than returning API error responses.
38-38:Details
✅ Verification successful
Verify error code consistency across components.
The error message "partner_not_found" should match the error codes defined in the auth component.
🏁 Script executed:
#!/bin/bash # Description: Verify error code consistency between PayPal callback route and auth component # Expected: Both files should use the same error codes echo "=== Error codes in PayPal callback route ===" rg -A 1 -B 1 'throw new Error\(' apps/web/app/\(ee\)/api/paypal/callback/route.ts echo -e "\n=== Error codes in auth component ===" rg -A 10 'ERROR_CODES.*=' apps/web/app/\(ee\)/partners.dub.co/\(dashboard\)/auth.tsxLength of output: 1087
No changes needed—error codes are consistent
The error strings thrown in apps/web/app/(ee)/api/paypal/callback/route.ts
(“partner_not_found”, “invalid_state”, “paypal_email_not_verified”) exactly match the keys in ERROR_CODES in apps/web/app/(ee)/partners.dub.co/(dashboard)/auth.tsx.apps/web/app/(ee)/partners.dub.co/(dashboard)/auth.tsx (4)
6-8: LGTM: Appropriate imports for error handling functionality.The added imports support the new error handling feature with URL parameter reading and user notifications.
10-18: Well-structured error code mapping with user-friendly messages.The ERROR_CODES object provides clear, actionable error messages that guide users on how to resolve issues. The mapping covers all the error scenarios from the PayPal callback route.
Note: The error codes match the ones thrown in the PayPal callback route, ensuring consistency across the error handling flow.
21-21: Proper use of useSearchParams for error handling.The hook correctly reads URL search parameters to detect errors passed from the callback route.
25-31: Effective error feedback implementation with proper cleanup.The useEffect properly reads error parameters and displays toast notifications. The fallback error message ensures users always receive feedback even for unexpected error codes.
The implementation correctly depends on
searchParamsto re-run when URL parameters change.
Summary by CodeRabbit
Bug Fixes
Chores