From 9f6253eb04f0ba7937f7c34733ea762ff83bdd6b Mon Sep 17 00:00:00 2001 From: AI Bot Date: Sun, 8 Nov 2026 14:01:24 -0500 Subject: [PATCH] fix(transporte): allow phone/whatsapp as identifier in send-otp and verify-otp --- transporte-cali-buenaventura/backend/src/index.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/transporte-cali-buenaventura/backend/src/index.ts b/transporte-cali-buenaventura/backend/src/index.ts index 1a5a3e2..d1f7e00 100644 --- a/transporte-cali-buenaventura/backend/src/index.ts +++ b/transporte-cali-buenaventura/backend/src/index.ts @@ -81,20 +81,23 @@ const server = http.createServer(async (req, res) => { // 1.1. Autenticación: Enviar OTP de seguridad por WhatsApp & Email if (pathname === '/api/auth/send-otp' && req.method === 'POST') { const body = await getJsonBody(); - if (!body.identifier) { + const identifier = body.identifier || body.phone || body.whatsapp; + if (!identifier) { return sendJson(400, { success: false, error: 'Se requiere número de WhatsApp o identificador' }); } - const result = await authService.sendOtp(body.identifier, body.email); + const result = await authService.sendOtp(identifier, body.email); return sendJson(result.success ? 200 : 400, result); } // 1.2. Autenticación: Validar OTP de 6 dígitos e iniciar sesión / registro if (pathname === '/api/auth/verify-otp' && req.method === 'POST') { const body = await getJsonBody(); - if (!body.identifier || !body.code) { + const identifier = body.identifier || body.phone || body.whatsapp; + const code = body.code || body.otp; + if (!identifier || !code) { return sendJson(400, { success: false, error: 'Identificador y código OTP requeridos' }); } - const result = await authService.verifyOtp(body); + const result = await authService.verifyOtp({ ...body, identifier, code }); return sendJson(result.success ? 200 : 400, result); }