Skip to content

fix(auth): route email confirmation and password reset through callback#27

Draft
julianromli wants to merge 1 commit into
mainfrom
ntfd/auth-module-issue-1fba
Draft

fix(auth): route email confirmation and password reset through callback#27
julianromli wants to merge 1 commit into
mainfrom
ntfd/auth-module-issue-1fba

Conversation

@julianromli

Copy link
Copy Markdown
Owner

Summary

This repo does not have src/auth.py (Python); auth lives in the Next.js/Supabase module under lib/server/auth.ts, lib/actions/*, and app/auth/callback. This PR fixes several related auth bugs in that module.

Changes

Email confirmation redirect chain

  • Signup, resend, and server-side auth actions previously redirected users to / or a bare site URL instead of /auth/callback.
  • Confirmation links now go through /auth/callback, where exchangeCodeForSession runs, profiles are created, and users get the correct post-confirm flow.

Password reset flow

  • Reset emails now redirect to /auth/callback?next=/user/auth/reset-password.
  • Added /user/auth/reset-password page for setting a new password after the recovery link.
  • Updated proxy.ts so recovery sessions are not redirected away from the reset page.

Admin authorization

  • deleteBlogPost checked user_metadata.role instead of the database users.role, so admins could be blocked from deleting posts. It now reads users.role like other admin actions.

Auth module consolidation

  • lib/server/auth.ts getCurrentUser() now delegates to lib/actions/user.ts while preserving the existing return shape for route consumers.

Centralized redirect helpers

  • Added getAuthCallbackUrl() / getClientAuthCallbackUrl() in lib/constants/auth.ts to avoid inconsistent redirect URLs.

Testing

  • bunx tsc --noEmit (no new auth-related errors; pre-existing unrelated errors remain)
  • Manual: signup → confirm email → lands on auth with success message
  • Manual: forgot password → reset link → set new password → sign in

Notes

Ensure Supabase dashboard redirect URLs include /auth/callback (see docs/security/AUTH_DASHBOARD_SETTINGS.md).

Open in Web Open in Cursor 

- Add centralized getAuthCallbackUrl helpers in lib/constants/auth.ts
- Point signup, resend, and reset email links at /auth/callback
- Handle password recovery flow in callback and new reset-password page
- Fix deleteBlogPost admin check to use users.role from database
- Consolidate server getCurrentUser with lib/actions/user implementation
- Allow reset-password route in proxy auth redirect logic

Co-authored-by: faizntfd <faizintfd@gmail.com>
@vercel

vercel Bot commented May 19, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
vibedevid Ready Ready Preview, Comment, Open in v0 May 19, 2026 5:21am

@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1ecea11d-4a3c-40a8-bd26-cf3cc21024e9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ntfd/auth-module-issue-1fba

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

2 participants