fix: prevent users from inviting themselves in referral flow#385
fix: prevent users from inviting themselves in referral flow#385jhosepm352-design wants to merge 1 commit into
Conversation
Greptile SummaryThis PR aims to prevent self-invites in the referral flow by filtering out the requesting user's own email before sending invitations. However, the diff accidentally removed the first 88 lines of
Confidence Score: 1/5Do not merge — the file is missing all imports, the GET handler, and the POST function declaration, making the entire /api/referrals endpoint non-functional. The diff deleted the first 88 lines of the file, including all import statements, the complete GET handler, and the opening of the POST function. What remains is a code fragment that references variables like src/app/api/referrals/route.ts needs to be restored to include its imports, the GET handler, and the complete POST function declaration before the new self-invite filter lines are inserted. Important Files Changed
|
| const validEmails = normalizedEmails.filter((e: string) => emailRegex.test(e)); | ||
| const userEmail = user.email?.toLowerCase(); | ||
| const filteredEmails = validEmails.filter((e: string) => e !== userEmail); |
There was a problem hiding this comment.
Entire route file is broken — imports, GET handler, and POST function declaration are all gone
The diff replaced lines 1–88 of the original file (all imports, the full GET handler, and the top ~80 lines of the POST handler including the function declaration, auth check, body parsing, and all early validation) with just 3 lines that reference variables that no longer exist: normalizedEmails, emailRegex, user, supabase, NextResponse, createServiceClient, referralInviteEmail, and sendEmail are all used later in the file but are never imported or declared. The module also no longer exports GET or POST, so Next.js will not route any requests to it. This file cannot compile and the entire /api/referrals endpoint is dead.
Prevents users from sending invitation emails to their own email address, avoiding potential gaming of the referral system.