feat(auth): recover a password with a code sent by email

Enable BetterAuth's emailOTP plugin for password resets: a 6-digit code,
valid for 10 minutes with 3 attempts, stored hashed in `verifications`
(no migration). The code goes out through the existing Resend mailer with
a new Spanish template, and other sessions are revoked after the reset.

The web app gets a two-step /forgot-password route (request the code,
then set the new password) linked from sign-in. Unknown emails get the
same responses as known ones so the form doesn't reveal accounts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-10-29 10:13:15 -03:00
parent 9bd2cc9089
commit 2117188bf9
8 changed files with 389 additions and 7 deletions

View File

@@ -6,7 +6,7 @@ BETTER_AUTH_URL="http://localhost:4100"
NODE_ENV="development"
# Optional: Pino log level (defaults to "debug" outside production, "info" in production)
# LOG_LEVEL="info"
# Resend API key used to send invitation emails. Without it, emails are logged instead.
# Resend API key used to send invitation and password reset emails. Without it, emails are logged instead.
# RESEND_API_KEY="re_xxxxxxxx"
# From address for outgoing email (must be a verified Resend sender)
# MAIL_FROM="Superlist <invitaciones@superlist.app>"