Skip to content

feat(auth,mail): fix OAuth redirect and add Resend email provider - #208

Merged
Gautam25Raj merged 2 commits into
masterfrom
fix/auth-redirect-and-resend-mail
Sep 30, 2026
Merged

Gautam25Raj merged 2 commits into
masterfrom
fix/auth-redirect-and-resend-mail

Conversation

@Gautam25Raj

Copy link
Copy Markdown
Collaborator

Description

This PR resolves two core authentication and infrastructure improvements:

  1. OAuth cancellation redirect fix:

    • When users cancelled third-party OAuth consent (Google or GitHub), Better Auth defaulted error redirects to https://api.veriworkly.com/?error=access_denied..., leaving users on raw API JSON.
    • Configured onAPIError: { errorURL: config.auth.studioLoginUrl } in server auth options so failed or cancelled OAuth flows redirect to Studio /login.
    • Updated Studio login page to parse OAuth errors via useSearchParams(), display a user-friendly error toast, and clean up query parameters from the address bar.
    • Removed direct window object references in SocialAuth.tsx in favor of Next.js navigation hooks and site config URLs.
  2. Resend email integration and SMTP connection pooling:

    • Added native Resend provider support (AUTH_EMAIL_PROVIDER=resend) using the official resend SDK and RESEND_API_KEY.
    • Updated production runtime validation (validateAuthRuntimeConfig) to accept both resend and smtp in production, verifying RESEND_API_KEY when Resend is selected.
    • Upgraded Nodemailer SMTP transport with connection pooling (pool: true, maxConnections: 5) and socket timeouts so that SMTP relays do not hang or exhaust sockets under load.
    • Added comprehensive unit tests for Resend dispatch, missing credentials, API errors, and runtime validation.
    • Updated environment variable documentation across .env.example, .env.docker.example, compose.yaml, and docs platform.

Linked Issue

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🧪 Tests (adding or updating tests)

Checklist

  • I have read the CONTRIBUTING.md document.
  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • Any dependent changes have been merged and published in downstream modules.

@Gautam25Raj Gautam25Raj added bug Something isn't working enhancement New feature or request frontend UI/client-side code backend server-side logic api API-related changes or issues labels Sep 30, 2026
@Gautam25Raj
Gautam25Raj merged commit f2d6984 into master Sep 30, 2026
11 checks passed
@Gautam25Raj
Gautam25Raj deleted the fix/auth-redirect-and-resend-mail branch October 4, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api API-related changes or issues backend server-side logic bug Something isn't working enhancement New feature or request frontend UI/client-side code

Projects

None yet

1 participant