enviar datos correctos al responsable
This commit is contained in:
@@ -4,6 +4,7 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const cancelar = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800);
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then((res) => {
|
||||
|
||||
@@ -14,7 +14,9 @@ const cartaTermino = async (body, file) => {
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
case 8:
|
||||
let path = `./server/uploads/${validar.validar(file, 'El archivo')}`;
|
||||
let path = `./server/uploads/${
|
||||
(validar.validar(file, 'El archivo'), 1000)
|
||||
}`;
|
||||
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
|
||||
@@ -14,7 +14,11 @@ const informeGlobal = async (body, file) => {
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
case 9:
|
||||
let path = `./server/uploads/${validar.validar(file, 'El archivo')}`;
|
||||
let path = `./server/uploads/${validar.validar(
|
||||
file,
|
||||
'El archivo',
|
||||
1000
|
||||
)}`;
|
||||
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
|
||||
@@ -15,12 +15,18 @@ const nuevo = async (body, file) => {
|
||||
let correo = validar.validarCorreo(body.correo);
|
||||
let fechaInicio = validar.validarFecha(body.fechaInicio);
|
||||
let fechaFin = validar.validarFecha(body.fechaFin);
|
||||
let path = `./server/uploads/${validar.validar(file, 'El archivo')}`;
|
||||
let path = `./server/uploads/${validar.validar(file, 'El archivo', 1000)}`;
|
||||
let carpeta = '';
|
||||
let programaInterno = body.programaInterno
|
||||
? validar.validarTexto(body.programaInterno)
|
||||
? validar.validarTexto(
|
||||
body.programaInterno,
|
||||
'El texto programa interno.',
|
||||
80
|
||||
)
|
||||
: '';
|
||||
let profesor = body.profesor
|
||||
? validar.validarTexto(body.profesor, 'El texto de profesor.', 50)
|
||||
: '';
|
||||
let profesor = body.profesor ? validar.validarTexto(body.profesor) : '';
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
|
||||
@@ -9,7 +9,7 @@ const registroValidado = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let fechaNacimiento = validar.validarFecha(body.fechaNacimiento);
|
||||
let telefono = validar.validarNumero(body.telefono, 10);
|
||||
let direccion = validar.validar(body.direccion, 'La dirección', 200);
|
||||
let direccion = validar.validarAlfanumerico(body.direccion, 'La dirección', 200);
|
||||
let correoAlumno = {};
|
||||
let correoResponsable = {};
|
||||
let emailResponsable = '';
|
||||
|
||||
@@ -11,7 +11,7 @@ const serviciosAdmin = async (body) => {
|
||||
let idUsuario = validar.validarId(body.idUsuario);
|
||||
let idStatus = body.idStatus ? validar.validarId(body.idStatus) : null;
|
||||
let nombre = body.nombre
|
||||
? validar.validarTexto(body.nombre, 'El nombre')
|
||||
? validar.validarTexto(body.nombre, 'El nombre', 60)
|
||||
: '';
|
||||
let numeroCuenta = body.numeroCuenta
|
||||
? validar.validarNumeroCuenta(body.numeroCuenta)
|
||||
|
||||
@@ -12,7 +12,7 @@ const serviciosResponsable = async (body) => {
|
||||
let idUsuario = validar.validarId(body.idUsuario);
|
||||
let idStatus = body.idStatus ? validar.validarId(body.idStatus) : null;
|
||||
let nombre = body.nombre
|
||||
? validar.validarTexto(body.nombre, 'El nombre')
|
||||
? validar.validarTexto(body.nombre, 'El nombre', 60)
|
||||
: '';
|
||||
let numeroCuenta = body.numeroCuenta
|
||||
? validar.validarNumeroCuenta(body.numeroCuenta)
|
||||
@@ -50,7 +50,7 @@ const serviciosResponsable = async (body) => {
|
||||
idServicio: res[i].idServicio,
|
||||
fechaInicio: res[i].fechaInicio,
|
||||
fechaFin: res[i].fechaFin,
|
||||
idCuestionarioAlumno: res[i].idCuestionarioAlumno,
|
||||
cartaTermino: res[i].cartaTermino,
|
||||
idCuestionarioPrograma: res[i].idCuestionarioPrograma,
|
||||
Usuario: {
|
||||
idUsuario: res[i].Usuario.idUsuario,
|
||||
|
||||
@@ -5,8 +5,8 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
const TipoUsuario = require('../../db/tablas/TipoUsuario');
|
||||
|
||||
const login = async (body) => {
|
||||
let usuario = validar.validar(body.usuario, 'El usuario');
|
||||
let password = validar.validar(body.password, 'El password');
|
||||
let usuario = validar.validar(body.usuario, 'El usuario', 60);
|
||||
let password = validar.validarAlfanumerico(body.password, 'El password', 20);
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { usuario, activo: true },
|
||||
|
||||
@@ -7,9 +7,11 @@ const responsable = async (body) => {
|
||||
let pagina = validar.validarId(body.pagina);
|
||||
let idUsuario = validar.validarId(body.idUsuario);
|
||||
let nombre = body.nombre
|
||||
? validar.validarTexto(body.nombre, 'El nombre')
|
||||
? validar.validarTexto(body.nombre, 'El nombre', 60)
|
||||
: '';
|
||||
let correo = body.correo
|
||||
? validar.validar(body.correo, 'El correo', 1000)
|
||||
: '';
|
||||
let correo = body.correo ? validar.validar(body.correo, 'El correo') : '';
|
||||
|
||||
return Usuario.findOne({ where: { idUsuario } })
|
||||
.then((res) => {
|
||||
|
||||
@@ -46,9 +46,9 @@ const caracteresEspeciales = (char) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
const validarTexto = (texto, campo) => {
|
||||
const validarTexto = (texto, campo, length) => {
|
||||
noHay(texto, campo);
|
||||
if (typeof texto !== 'string') noValido(campo);
|
||||
if (typeof texto !== 'string' || texto.length > length) noValido(campo);
|
||||
for (let i = 0; i < texto.length; i++) {
|
||||
if (caracteresEspeciales(texto[i])) continue;
|
||||
if (!validator.isAlpha(texto[i], 'es-ES')) noValido(campo);
|
||||
@@ -56,9 +56,9 @@ const validarTexto = (texto, campo) => {
|
||||
return texto;
|
||||
};
|
||||
|
||||
const validarAlfanumerico = (texto, campo) => {
|
||||
const validarAlfanumerico = (texto, campo, length) => {
|
||||
noHay(texto, campo);
|
||||
if (typeof texto !== 'string') noValido(campo);
|
||||
if (typeof texto !== 'string' || texto.length > length) noValido(campo);
|
||||
for (let i = 0; i < texto.length; i++) {
|
||||
if (caracteresEspeciales(texto[i])) continue;
|
||||
if (!validator.isAlphanumeric(texto[i], 'es-ES')) noValido(campo);
|
||||
|
||||
Reference in New Issue
Block a user