Skip to content

Refactor OTP sign-in to server-side API and fix callback errors#79

Merged
XploY04 merged 7 commits into
pointblank-club:stagingfrom
jayantkageriofficial:staging
May 28, 2026
Merged

Refactor OTP sign-in to server-side API and fix callback errors#79
XploY04 merged 7 commits into
pointblank-club:stagingfrom
jayantkageriofficial:staging

Conversation

@jayantkageri

Copy link
Copy Markdown
Contributor

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:

  • Feature implementation
  • Bug fix
  • Documentation update
  • Code refactoring
  • Configuration changes
  • Other (please specify)

Type of Change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update
  • Performance improvement
  • Code cleanup or refactor

How Has This Been Tested?

Describe the tests you ran:

  • Unit tests
  • Integration tests
  • Manual tests
  • Other (please specify)

Please describe the test cases and expected behavior:

  1. The Email Check should happen on the server side also
  2. The Supabase OTP has to be sent from server side

Screenshots (if applicable)

Dependencies

Documentation

  • I have updated the documentation accordingly
  • Documentation update is not required

Comments:

Reviewer Notes

jayantkageri and others added 5 commits May 27, 2026 22:45
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>
@netlify

netlify Bot commented May 27, 2026

Copy link
Copy Markdown

👷 Deploy request for pb-placement pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 2c971bb

@github-actions github-actions Bot added Frontend Auto-generated label for Frontend changes size-M Auto-generated label for size-M changes Utils Auto-generated label for Utils changes size-L Auto-generated label for size-L changes and removed size-M Auto-generated label for size-M changes labels May 27, 2026
@github-actions github-actions Bot added size-M Auto-generated label for size-M changes and removed size-L Auto-generated label for size-L changes labels May 27, 2026
Comment thread app/api/email-sign-in/route.ts Outdated
Comment thread app/api/email-sign-in/route.ts Outdated
@github-actions github-actions Bot added size-M Auto-generated label for size-M changes and removed size-M Auto-generated label for size-M changes labels May 28, 2026
@jayantkageri jayantkageri requested a review from ShreyashSri May 28, 2026 16:11
@XploY04 XploY04 merged commit 4c36b0d into pointblank-club:staging May 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend Auto-generated label for Frontend changes size-M Auto-generated label for size-M changes Utils Auto-generated label for Utils changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants