Mejorar verificacion por email y OAuth de Google para despliegue en sinbad2.

Endurece el envio SMTP (EHLO/STARTTLS, timeouts, errores tipados y logging), centraliza el manejo de fallos en registro y reenvio, codifica la redirect_uri de Google OAuth y documenta la configuracion de produccion en .env.example.
This commit is contained in:
Mireya Cueto Garrido
2026-05-21 12:14:17 +02:00
parent 2b7428df56
commit 6d87a32bc4
4 changed files with 230 additions and 53 deletions
+32 -3
View File
@@ -15,7 +15,11 @@
# Esta URI debe estar registrada también en la consola de Google Cloud.
GOOGLE_CLIENT_ID=tu-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=tu-client-secret
GOOGLE_REDIRECT_URI=http://localhost:8070/api/auth/google/callback
# URI a la que Google redirige tras el login (debe estar registrada en Google Cloud)
# Con Docker: suele ser el frontend (8071) porque /api hace proxy al backend
GOOGLE_REDIRECT_URI=http://localhost:8071/api/auth/google/callback
# Producción (añade la misma URI en Google Console → Credenciales OAuth):
# GOOGLE_REDIRECT_URI=http://tu-servidor:8071/api/auth/google/callback
# Clave para firmar los JWT (usa algo largo y aleatorio en producción)
SECRET_KEY=cambia-esta-clave-en-produccion
@@ -27,16 +31,41 @@ SECRET_KEY=cambia-esta-clave-en-produccion
FRONTEND_URL=http://localhost:5173
# Verificación de email por código numérico
# Si SMTP_HOST no está configurado, el backend imprimirá el código en consola.
# El destinatario puede ser cualquier proveedor (Gmail, Hotmail, Outlook, etc.).
# El fallo de envío suele deberse a SMTP mal configurado, no al dominio del usuario.
EMAIL_VERIFICATION_CODE_TTL_MINUTES=15
EMAIL_VERIFICATION_MAX_ATTEMPTS=5
EMAIL_VERIFICATION_SECRET=cambia-este-secreto-en-produccion
# SMTP para enviar los códigos de verificación
# Solo desarrollo local: imprime el código en logs si SMTP falla o no existe
# EMAIL_VERIFICATION_DEV_LOG_CODE=true
# Muestra el error SMTP real en la respuesta HTTP (no usar en producción)
# EMAIL_VERIFICATION_SHOW_ERRORS=true
# SMTP para enviar los códigos de verificación (cuenta REMITENTE, no la del usuario)
# Gmail: crea una "Contraseña de aplicación" en https://myaccount.google.com/apppasswords
# SMTP_HOST=smtp.gmail.com
# SMTP_PORT=587
# SMTP_USE_TLS=true
# SMTP_USE_SSL=false
# SMTP_USERNAME=tu-correo@gmail.com
# SMTP_PASSWORD=xxxx-xxxx-xxxx-xxxx
# SMTP_FROM_EMAIL=tu-correo@gmail.com
# Outlook / Hotmail / Microsoft 365 (cuenta remitente @outlook.com, @hotmail.com, etc.)
# SMTP_HOST=smtp-mail.outlook.com
# SMTP_PORT=587
# SMTP_USE_TLS=true
# SMTP_USE_SSL=false
# SMTP_USERNAME=tu-correo@hotmail.com
# SMTP_PASSWORD=tu-contraseña-o-app-password
# SMTP_FROM_EMAIL=tu-correo@hotmail.com
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USE_TLS=true
SMTP_USE_SSL=false
SMTP_TIMEOUT_SECONDS=30
SMTP_USERNAME=tu-correo@gmail.com
SMTP_PASSWORD=tu-password-o-app-password
SMTP_FROM_EMAIL=tu-correo@gmail.com