diff --git a/server.js b/server.js index e8d41a6..6039bb9 100644 --- a/server.js +++ b/server.js @@ -383,10 +383,13 @@ async function requirePlan(req, res, next, feature) { app.post("/auth/login", async (req, res) => { try { - const { identifier, password } = req.body; + // 🚨 MEJORA: Aceptamos identifier, email o phone para que no falle nunca con el frontend + const identifier = req.body.identifier || req.body.email || req.body.phone; + const password = req.body.password; + if (!identifier || !password) return res.status(400).json({ ok: false, error: "Faltan datos" }); - const identClean = identifier.replace(/\s+/g, '').trim(); + const identClean = String(identifier).replace(/\s+/g, '').trim(); // Buscamos al usuario por email o por teléfono (con o sin +34) const q = await pool.query(