Skip to content

refactor(auth): replace SMTP with Mailjet, simplify login flow, and fix signup validation#65

Merged
Atanu2k4 merged 2 commits into
sanks011:masterfrom
Atanu2k4:master
Jun 2, 2026
Merged

refactor(auth): replace SMTP with Mailjet, simplify login flow, and fix signup validation#65
Atanu2k4 merged 2 commits into
sanks011:masterfrom
Atanu2k4:master

Conversation

@Atanu2k4

@Atanu2k4 Atanu2k4 commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Replaces the entire SMTP/Nodemailer email stack with the Mailjet API for transactional email delivery. Refactors the authentication flow so that email OTP verification is only required during sign-up (to confirm the email address) and after a 30-day session expires (re-login). Regular sign-in now creates a session directly without an OTP step. Also removes the disposable email detection system and fixes a bug where sign-up could be submitted with an empty confirm-password field.

Related issue

Fixes #64

Changes

Email Provider

  • Removed nodemailer, disposable-email-domains, @visulima/disposable-email-domains, and @types/nodemailer packages
  • Installed node-mailjet and rewrote lib/notifyMail.ts to use the Mailjet Send API v3.1
  • Replaced SMTP_* and BREVO_API_KEY env vars with MAILJET_API_KEY, MAILJET_API_SECRET, MAILJET_FROM_EMAIL, MAILJET_FROM_NAME

Removed Files

  • lib/emailGuard.ts — disposable email detection (3-layer: blocklist + DNS MX)
  • lib/disposable-domains.json — 72k+ domain blocklist (1.2 MB)
  • lib/validateConfig.ts — SMTP env var startup validator
  • app/api/admin/refresh-email-blocklist/route.ts — admin endpoint to refresh blocklist

Auth Flow Refactor

  • Sign-up: Name + Email + Password + Confirm Password → OTP verification email sent → verify code → account created + 30-day session (unchanged)
  • Sign-in: Email + Password → 30-day session created directly, no OTP required
  • After 30 days: Session expires → user signs in again → OTP email sent at that point
  • app/api/auth/login/route.ts — removed OTP generation and email send; now creates LoginSession directly and returns { user, sessionToken, expiresAt }
  • context/AuthContext.tsx — removed requiresOtp branch from login(); regular login now expects session directly
  • components/ApplyModal.tsxSignInForm stripped of all OTP state and UI; simple email + password → redirect flow

Bug Fix

  • components/ApplyModal.tsxSignUpForm now explicitly blocks form submission when confirm password is empty, showing a "Please confirm your password" toast

Cleanup

  • server.ts — removed logConfigStatus() import and startup call
  • app/api/auth/signup/route.ts — removed isDisposableEmail import and guard block
  • app/api/auth/otp/send/route.ts — removed SMTP-specific error codes (EAUTH, 535, ECONNREFUSED, ETIMEDOUT)

Testing

  • Sign up with a new email → OTP verification email received via Mailjet → verify code → redirected to dashboard
  • Sign in with existing credentials → redirected to dashboard immediately, no OTP prompt
  • Sign up with mismatched passwords → error toast shown
  • Sign up with empty confirm password field → "Please confirm your password" toast shown (bug fix verified)
  • Session persists across browser reloads for up to 30 days
  • After session expiry, sign-in triggers OTP flow

Checklist

  • Title follows the repository PR format
  • The issue is linked with Fixes #64
  • Testing notes are included

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

PR Validation Passed

Your PR title and description meet all requirements:

1 similar comment
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

PR Validation Passed

Your PR title and description meet all requirements:

@Atanu2k4 Atanu2k4 merged commit 9a95c41 into sanks011:master Jun 2, 2026
2 checks passed
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.

mail verification not working

1 participant