Actualizar server.js

This commit is contained in:
2026-03-08 20:29:18 +00:00
parent 263e622026
commit 99147e9955

View File

@@ -424,8 +424,6 @@ function extractValidPhone(rawPhone) {
const digits = str.replace(/\D/g, ""); // Si falla, coge los primeros 9 números que pille
return digits.length >= 9 ? digits.substring(0, 9) : digits;
}
function normalizePhone(phone) { let p = String(phone || "").trim().replace(/\s+/g, "").replace(/-/g, ""); if (!p) return ""; if (!p.startsWith("+") && /^[6789]\d{8}/.test(p)) return "+34" + p; return p; }
function normalizePhone(phone) { let p = String(phone || "").trim().replace(/\s+/g, "").replace(/-/g, ""); if (!p) return ""; if (!p.startsWith("+") && /^[6789]\d{8}/.test(p)) return "+34" + p; return p; }
function signToken(user) { const accountId = user.owner_id || user.id; return jwt.sign({ sub: user.id, email: user.email, phone: user.phone, role: user.role || 'operario', accountId }, JWT_SECRET, { expiresIn: "30d" }); }