fix(auth): handle interrupted oauth flows gracefully without triggeri…#2275
Open
MoonLawlier wants to merge 1 commit into
Open
fix(auth): handle interrupted oauth flows gracefully without triggeri…#2275MoonLawlier wants to merge 1 commit into
MoonLawlier wants to merge 1 commit into
Conversation
|
Someone is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel. A member of the Team first needs to authorize it. |
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
Owner
|
This PR now has merge conflicts (likely from recent merges to main affecting package-lock.json). The code changes look good — please rebase on latest main, resolve the conflicts, and this can be merged. |
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
Fixes the interrupted GitHub OAuth retry flow by preventing cancelled sign-in starts from tripping the auth rate limiter, and redirects real auth throttles back to the sign-in UI instead of showing raw JSON. Also hardens Supabase env validation so malformed local URLs no longer crash the app at startup.
Closes #2267
Type of Change
What Changed
src/lib/auth-rate-limit.tsso OAuth initiation routes like/api/auth/signin/githubare no longer rate-limited, while callback/code-exchange routes remain protected.src/middleware.tsto redirect auth rate-limit failures to/auth/signin?error=RateLimitinstead of returning raw JSON.src/app/auth/signin/page.tsxto show a user-friendlyRateLimittoast/message.src/lib/supabase-env.tsand updated Supabase clients to avoid crashing when Supabase URL env vars are malformed.test/auth-rate-limit.test.tsandtest/supabase-guard.test.tswith regression coverage.How to Test
npx vitest run test/auth-rate-limit.test.ts test/supabase-guard.test.ts.npm run type-check.npm run lint.Expected result:
The interrupted OAuth flow can be retried without hitting a hard block. If auth rate limiting is triggered, the user is redirected back to the sign-in page with a friendly message instead of raw JSON. The app should also start without crashing when Supabase env URLs are malformed.
Screenshots / Recordings
|
Checklist
console.log, debug code, or commented-out blocksnpm run lintpasses locallynpm run type-check)Accessibility (UI changes only)
Additional Context
package-lock.jsonwas already modified before these changes and was not touched as part of this fix.