From 5053ab788c120e50eacc2af16ed1471db02e99b0 Mon Sep 17 00:00:00 2001 From: DanielRamirezGe Date: Wed, 9 Oct 2019 18:37:49 -0500 Subject: [PATCH] actualizacion del registro Persona --- routes/registroPersona.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/routes/registroPersona.js b/routes/registroPersona.js index d43cb2a..ea2c325 100644 --- a/routes/registroPersona.js +++ b/routes/registroPersona.js @@ -9,7 +9,7 @@ app.post('/registroPersona', async(req, res) => { //console.log(req.body); var pass = await bcrypt.hash(req.body.password, 10); - console.log(pass); + //console.log(pass); let mail = await validator.isEmail(req.body.correo); if (!mail) { @@ -52,8 +52,7 @@ app.post('/registroPersona', async(req, res) => { // console.log(results.length); if (results.length == 0) { - if (req.query.noCuenta == null) - req.query.noCuenta = -999; + await connection.query(`select * from persona where noCuenta=${req.body.noCuenta};`, async(error, results, fields) => { if (error) { @@ -61,13 +60,12 @@ app.post('/registroPersona', async(req, res) => { return; } - if (results.length > 0) { + if (results.length > 0 && req.body.noCuenta != null) { res.status(400).json({ err: true, mjs: 'el numero de cuenta ya esta registrado' }); return; } else { //insert into persona values(null, '312312', 8.9, 'daniel', 'ramirez', 'homrbe', 21, 'daniel|gmail.com','avanzado', 'externo', 'dasdasda', 'chido', 'acturia', ) - if (req.query.noCuenta == -999) - req.query.noCuenta = null; + await connection.query(`insert into persona values (${req.body.est}, '${req.body.noCuenta}', ${req.body.promedio}, '${req.body.nombre}', '${req.body.apellidos}', '${req.body.sexo}', ${req.body.edad}, '${req.body.correo}', '${req.body.nivelIngles}', '${req.body.comunidad}' , '${pass}', '${req.body.facultad}' , '${req.body.gradoAcademico}',