Fix magic link delivery errors and resend cooldown UX#35
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR implements end-to-end magic-link request cooldown enforcement. The API route computes ChangesMagic-link request cooldown enforcement
Sequence DiagramsequenceDiagram
participant User
participant Frontend as Login/Signup Page
participant Service as signInWithOtp
participant API as /api/auth/magic-link
participant Supabase
User->>Frontend: Submit OTP request
Frontend->>Service: signInWithOtp(email)
Service->>API: POST with email
API->>Supabase: signInWithOtp call
alt Supabase error or rate-limit
Supabase-->>API: error response
API->>API: normalizeSupabaseAuthError<br/>compute retryAfter
API-->>Service: { error, retryAfter }
else Success
Supabase-->>API: success
API-->>Service: { success: true }
end
Service-->>Frontend: { success, error?, retryAfter? }
Frontend->>Frontend: Set cooldownSeconds<br/>from retryAfter or constant
Frontend->>Frontend: Decrement timer<br/>block new requests
Frontend->>User: Show countdown + disabled button
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
This PR hardens the magic-link sign-in/sign-up flow so users no longer hit confusing 502 Bad Gateway responses or repeatedly trigger Supabase's per-user email interval.
Changes
Verification
npm.cmd exec eslint app/api/auth/magic-link/route.ts lib/features/auth/auth-service.ts app/login/page.tsx app/signup/page.tsxnpm.cmd run buildNotes
Supabase is configured with
Minimum interval per user = 60, so the UI now mirrors that cooldown instead of letting users spam resend requests and receive confusing API failures.Summary by CodeRabbit