Actualizar server.js

This commit is contained in:
2026-03-05 14:39:01 +00:00
parent 07883dc5dd
commit f9784f8efa

View File

@@ -383,10 +383,13 @@ async function requirePlan(req, res, next, feature) {
app.post("/auth/login", async (req, res) => { app.post("/auth/login", async (req, res) => {
try { 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" }); 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) // Buscamos al usuario por email o por teléfono (con o sin +34)
const q = await pool.query( const q = await pool.query(