Skip to content

Cursor/critical correctness bugs 3a41#64

Open
DealPatrol wants to merge 3 commits into
mainfrom
cursor/critical-correctness-bugs-3a41
Open

Cursor/critical correctness bugs 3a41#64
DealPatrol wants to merge 3 commits into
mainfrom
cursor/critical-correctness-bugs-3a41

Conversation

@DealPatrol

Copy link
Copy Markdown
Owner

Merge to main

cursoragent and others added 3 commits May 25, 2026 11:10
Co-authored-by: Cole Collins <DealPatrol@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@vercel

vercel Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
repo-app-architect Error Error May 27, 2026 4:17pm
repofuse Error Error Open in v0 May 27, 2026 4:17pm
v0-repo-app-architect Error Error Open in v0 May 27, 2026 4:17pm

@supabase

supabase Bot commented May 27, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project bpjftwoiosftvjvxpovz because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to address critical correctness/security issues in authentication redirects and Stripe webhook processing by adding return URL sanitization, tightening cookie/token validation, and refactoring Stripe webhook handling to persist subscription state and grant credits.

Changes:

  • Added sanitizeReturnTo and wired it into GitHub OAuth login/callback to prevent unsafe redirect targets.
  • Tightened getCurrentUser() cookie/token validation to avoid accepting a DB user row when the request cookie token doesn’t match.
  • Refactored Stripe webhook route to map Stripe events into subscription/user billing updates and credit grants.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
lib/auth.ts Adds return-to sanitization helper and strengthens current-user validation against cookie token mismatches.
app/api/auth/github/login/route.ts Uses sanitizeReturnTo when persisting the OAuth “return to” location in cookies.
app/api/auth/github/callback/route.ts Uses sanitizeReturnTo when reading the OAuth “return to” cookie before redirecting.
app/api/stripe/webhook/route.ts Attempts major webhook refactor, but the file appears to contain unresolved merge/corruption (imports inside functions, duplicate handlers, mismatched braces) that will break compilation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +17 to 21
function parseGithubId(value: string | number | null | undefined): number | null {
if (value === null || value === undefined) {
return null
import { getStripe } from '@/lib/stripe'
import { upsertSubscription, getSubscriptionByStripeCustomerId, getUserByGithubId } from '@/lib/queries'
Comment on lines +167 to +171
export async function POST(request: NextRequest) {
const body = await request.text()
const signature = request.headers.get('stripe-signature')

if (!signature || !process.env.STRIPE_WEBHOOK_SECRET || !process.env.STRIPE_SECRET_KEY) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants