Refactor OTP sign-in to server-side API and fix callback errors#79
Merged
Merged
Conversation
Previously, the domain check was done in /api/email-sign-in but the actual supabase.auth.signInWithOtp() call was made client-side, allowing anyone to bypass the domain restriction using the public anon key. - Move signInWithOtp() into the API route using SUPABASE_SERVICE_ROLE_KEY - Domain validation and OTP trigger are now atomic and server-only - Remove direct Supabase auth call and import from the sign-in page - Derive emailRedirectTo from the request Origin header server-side Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add GET handler to /api/callback for PKCE code exchange - Guard POST /api/callback against null session (SIGNED_OUT event) to fix 'Cannot read properties of null (reading access_token)' - Update emailRedirectTo in /api/email-sign-in to point to /api/callback - Wrap authStore callback fetch in try/catch to prevent unhandled rejections Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
👷 Deploy request for pb-placement pending review.Visit the deploys page to approve it
|
ShreyashSri
suggested changes
May 28, 2026
ShreyashSri
approved these changes
May 28, 2026
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: What does this PR do?
Refactor OTP sign-in to server-side API and fix callback errors
Which issue(s) this PR fixes:
Changes Made
Describe the changes you've made in this PR:
Type of Change
How Has This Been Tested?
Describe the tests you ran:
Please describe the test cases and expected behavior:
Screenshots (if applicable)
Dependencies
Documentation
Comments:
Reviewer Notes