diff --git a/server/controller/Servicio/admin.js b/server/controller/Servicio/admin.js index b7fc44d..16cb27f 100644 --- a/server/controller/Servicio/admin.js +++ b/server/controller/Servicio/admin.js @@ -28,7 +28,6 @@ const admin = async (body) => { fechaInicio: res.fechaInicio, fechaFin: res.fechaFin, fechaNacimiento: res.fechaNacimiento, - carpeta: res.carpeta, cartaAceptacion: res.cartaAceptacion, cartaTermino: res.cartaTermino, informeGlobal: res.informeGlobal, @@ -64,7 +63,6 @@ const admin = async (body) => { clavePrograma: res.Programa.clavePrograma, acatlan: res.Programa.acatlan, activo: res.Programa.activo, - idUsuario: res.Programa.idUsuario, }, }; }); diff --git a/server/controller/Servicio/alumno.js b/server/controller/Servicio/alumno.js index a9b52a1..f6482cb 100644 --- a/server/controller/Servicio/alumno.js +++ b/server/controller/Servicio/alumno.js @@ -34,7 +34,6 @@ const alumno = async (body) => { fechaInicio: res.fechaInicio, fechaFin: res.fechaFin, fechaNacimiento: res.fechaNacimiento, - carpeta: res.carpeta, cartaAceptacion: res.cartaAceptacion, cartaTermino: res.cartaTermino, informeGlobal: res.informeGlobal, @@ -61,7 +60,6 @@ const alumno = async (body) => { clavePrograma: res.Programa.clavePrograma, acatlan: res.Programa.acatlan, activo: res.Programa.activo, - idUsuario: res.Programa.idUsuario, }, }; }); diff --git a/server/controller/Servicio/liberacion.js b/server/controller/Servicio/liberacion.js index 1cf1958..c6457e5 100644 --- a/server/controller/Servicio/liberacion.js +++ b/server/controller/Servicio/liberacion.js @@ -3,6 +3,7 @@ const gmail = require('../../helper/gmail'); const correos = require('../../helper/correos'); const Servicio = require('../../db/tablas/Servicio'); const Usuario = require('../../db/tablas/Usuario'); +// const Programa = require('../../db/tablas/Programa'); const liberacion = async (body) => { let idServicio = validar.validarId(body.idServicio); @@ -10,10 +11,16 @@ const liberacion = async (body) => { return Servicio.findOne({ where: { idServicio }, include: [{ model: Usuario }], + // include: [{ model: Usuario }, { model: Programa }], }) .then(async (res) => { if (!res) throw new Error('No existe este Servicio Social.'); - + /* + if (res.Programa.acatlan && !body.vistoBuenoAcatlan) + throw new Error( + 'El programa de este Servicio Solcial es Acatlán Contigo y no se envio la variable validando este servicio.' + ); + */ switch (res.idStatus) { case 5: let correo = correos.terminoValidado(res.Usuario.nombre); @@ -42,6 +49,12 @@ const liberacion = async (body) => { }) .then((res) => { return Servicio.update({ idStatus: 6 }, { where: { idServicio } }); + /* + let data = { idStatus: 6 }; + + if (body.vistoBuenoAcatlan) data.vistoBuenoAcatlan = true; + return Servicio.update(data, { where: { idServicio } }); + */ }) .then((res) => { return { diff --git a/server/controller/Servicio/nuevo.js b/server/controller/Servicio/nuevo.js index 6284078..e9c63d9 100644 --- a/server/controller/Servicio/nuevo.js +++ b/server/controller/Servicio/nuevo.js @@ -18,6 +18,7 @@ const nuevo = async (body, file) => { let path = `./server/uploads/${validar.validar(file, 'El archivo')}`; let carpeta = ''; let cartaAceptacion = ''; + // let programaInterno = validar.validarTexto return Usuario.findOne({ where: { idUsuario }, diff --git a/server/helper/validar.js b/server/helper/validar.js index 252ab3c..806c2f5 100644 --- a/server/helper/validar.js +++ b/server/helper/validar.js @@ -39,16 +39,33 @@ const validarCorreo = (correo) => { return correo; }; +const caracteresEspeciales = (char) => { + const charset = [' ', '.', '-', ',', '/', '#']; + + for (let i = 0; i < charset.length; i++) if (charset[i] === char) return true; + return false; +}; + const validarTexto = (texto, campo) => { noHay(texto, campo); if (typeof texto !== 'string') noValido(campo); for (let i = 0; i < texto.length; i++) { - if (texto[i] === ' ') continue; + if (caracteresEspeciales(texto[i])) continue; if (!validator.isAlpha(texto[i], 'es-ES')) noValido(campo); } return texto; }; +const validarAlfanumerico = (texto, campo) => { + noHay(texto, campo); + if (typeof texto !== 'string') noValido(campo); + for (let i = 0; i < texto.length; i++) { + if (caracteresEspeciales(texto[i])) continue; + if (!validator.isAlphanumeric(texto[i], 'es-ES')) noValido(campo); + } + return texto; +}; + const validarNumeroCuenta = (numeroCuenta) => { let campo = 'El numero de cuenta'; @@ -111,6 +128,7 @@ module.exports = { validarCorreo, validarId, validarTexto, + validarAlfanumerico, validarNumeroCuenta, validarFecha, validarNumero,