produccion

This commit is contained in:
Andres2908
2022-03-21 23:19:03 -06:00
21 changed files with 312 additions and 137 deletions
+32
View File
@@ -19,6 +19,7 @@
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"express": "^4.17.1", "express": "^4.17.1",
"fs": "^0.0.1-security", "fs": "^0.0.1-security",
"gmail-send": "^1.8.14",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
"mariadb": "^2.5.3", "mariadb": "^2.5.3",
"moment": "^2.29.1", "moment": "^2.29.1",
@@ -1071,6 +1072,15 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/gmail-send": {
"version": "1.8.14",
"resolved": "https://registry.npmjs.org/gmail-send/-/gmail-send-1.8.14.tgz",
"integrity": "sha512-hc+4Ej7ZJtw0G5sync10pmWkpPXIabkQ+p/a92lPPTXni3ChEU9sR2wxOvK6Hx+5Ou+2m9h1cVffWEgtR6Gzkw==",
"dependencies": {
"lodash": "^4.17.21",
"nodemailer": "^6.6.5"
}
},
"node_modules/got": { "node_modules/got": {
"version": "9.6.0", "version": "9.6.0",
"resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz",
@@ -1757,6 +1767,14 @@
"node": "4.x || >=6.0.0" "node": "4.x || >=6.0.0"
} }
}, },
"node_modules/nodemailer": {
"version": "6.7.2",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.7.2.tgz",
"integrity": "sha512-Dz7zVwlef4k5R71fdmxwR8Q39fiboGbu3xgswkzGwczUfjp873rVxt1O46+Fh0j1ORnAC6L9+heI8uUpO6DT7Q==",
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/nodemon": { "node_modules/nodemon": {
"version": "2.0.15", "version": "2.0.15",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.15.tgz", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.15.tgz",
@@ -3558,6 +3576,15 @@
"ini": "2.0.0" "ini": "2.0.0"
} }
}, },
"gmail-send": {
"version": "1.8.14",
"resolved": "https://registry.npmjs.org/gmail-send/-/gmail-send-1.8.14.tgz",
"integrity": "sha512-hc+4Ej7ZJtw0G5sync10pmWkpPXIabkQ+p/a92lPPTXni3ChEU9sR2wxOvK6Hx+5Ou+2m9h1cVffWEgtR6Gzkw==",
"requires": {
"lodash": "^4.17.21",
"nodemailer": "^6.6.5"
}
},
"got": { "got": {
"version": "9.6.0", "version": "9.6.0",
"resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz",
@@ -4092,6 +4119,11 @@
"whatwg-url": "^5.0.0" "whatwg-url": "^5.0.0"
} }
}, },
"nodemailer": {
"version": "6.7.2",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.7.2.tgz",
"integrity": "sha512-Dz7zVwlef4k5R71fdmxwR8Q39fiboGbu3xgswkzGwczUfjp873rVxt1O46+Fh0j1ORnAC6L9+heI8uUpO6DT7Q=="
},
"nodemon": { "nodemon": {
"version": "2.0.15", "version": "2.0.15",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.15.tgz", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.15.tgz",
+1
View File
@@ -27,6 +27,7 @@
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"express": "^4.17.1", "express": "^4.17.1",
"fs": "^0.0.1-security", "fs": "^0.0.1-security",
"gmail-send": "^1.8.14",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
"mariadb": "^2.5.3", "mariadb": "^2.5.3",
"moment": "^2.29.1", "moment": "^2.29.1",
+5 -5
View File
@@ -8,17 +8,17 @@ const pool = mariadb.createPool({
database: process.env.SAT_DB, database: process.env.SAT_DB,
}); });
const obtenerIdCarrera = async (numeroCuenta) => { const obtenerDatosUsr = async (numeroCuenta) => {
const conn = await pool.getConnection().catch((err) => { const conn = await pool.getConnection().catch((err) => {
throw new Error('No se pudo conectar con la db. ' + err); throw new Error('No se pudo conectar con la db. ' + err);
}); });
return conn return conn
.query(`SELECT id_carrera FROM alumno WHERE id_cuenta = ${numeroCuenta}`) .query(
`SELECT id_carrera, generacion FROM alumno WHERE id_cuenta = ${numeroCuenta}`
)
.then((rows) => { .then((rows) => {
conn.end(); conn.end();
// console.log(rows[0]);
// if (rows[0].length === 0) return null;
return rows[0]; return rows[0];
}) })
.catch((err) => { .catch((err) => {
@@ -63,4 +63,4 @@ const usuarioInscrito = async (numeroCuenta, realizoPago) => {
}); });
}; };
module.exports = { obtenerIdCarrera, obtenerCarrera, usuarioInscrito }; module.exports = { obtenerDatosUsr, obtenerCarrera, usuarioInscrito };
@@ -0,0 +1,57 @@
const dbPath = '../../db/tablas';
const { validarNumeroEntero } = require('../../helper/validar');
const { Op } = require('sequelize');
const Inscripcion = require(`${dbPath}/Inscripcion`);
const actualizarTicket = async (body) => {
const idInscripcion = validarNumeroEntero(
body.idInscripcion,
'id Inscripcion',
true
);
const monto = validarNumeroEntero(body.monto, 'monto', true);
const folio = validarNumeroEntero(body.folio, 'folio', true);
return Inscripcion.findOne({
where: {
idInscripcion,
},
})
.then((res) => {
if (!res) throw new Error('No pudimos encontrar este ticket.');
return Inscripcion.findOne({
where: {
folio,
cancelacion: 0,
idInscripcion: { [Op.ne]: idInscripcion },
},
});
})
.then((res) => {
if (res)
throw new Error('¡ Este folio ya fue utilizado por otra inscripción !');
})
.then((res) => {
return Inscripcion.update(
{
folio,
monto,
fechaTicket: body.fechaTicket,
},
{
where: {
idInscripcion,
},
}
);
})
.then((res) => ({
message:
'¡ Los datos de la inscripción fueron actualizados de forma correcta !',
}))
.catch((err) => {
throw new Error('No fue posible actualizar los datos del ticket. ' + err);
});
};
module.exports = actualizarTicket;
@@ -0,0 +1,36 @@
const dbPath = '../../db/tablas';
const Inscripcion = require(`${dbPath}/Inscripcion`);
const { validarNumeroEntero } = require('../../helper/validar');
const cancelarInscripcion = async (body) => {
const idInscripcion = validarNumeroEntero(
body.idInscripcion,
'id Inscripcion',
true
);
return Inscripcion.findOne({
where: { idInscripcion },
})
.then((res) => {
if (!res) throw new Error('Lo sentimos esta inscripción no existe.');
return Inscripcion.update(
{
cancelacion: 1,
},
{
where: {
idInscripcion,
},
}
);
})
.then((res) => ({
message: '¡ Esta inscripción fue cancelada de forma correcta !',
}))
.catch((err) => {
throw new Error('¡ No fue posible validar la inscripción !. ');
});
};
module.exports = cancelarInscripcion;
+23
View File
@@ -0,0 +1,23 @@
const { validarNumeroEntero } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Inscripcion = require(`${dbPath}/Inscripcion`);
const motivo = async (body) => {
const folio = validarNumeroEntero(body.folio, 'folio', true);
return Inscripcion.findOne({
where: { folio },
})
.then((res) => {
if (!res) throw new Error('No pudimos encontrar este ticket.');
return Inscripcion.findOne({
where: { folio, validacion: 0 },
attributes: ['motivo'],
});
})
.catch((err) => {
throw new Error('No fue posible encontrar el ticket. ' + err);
});
};
module.exports = motivo;
+11 -24
View File
@@ -29,30 +29,17 @@ const reporte = async (body) => {
], ],
}) })
.then(async (res) => { .then(async (res) => {
if (body.tipo === 'CSV') { for (let i = 0; i < res.length; i++) {
for (let i = 0; i < res.length; i++) { data.push({
data.push({ numeroCuenta: res[i].Usuario.numeroCuenta,
numero_cuenta: res[i].Usuario.numeroCuenta, idArea: res[i].idArea,
id_area: res[i].idArea, folio: res[i].folio,
folio: res[i].folio, monto: res[i].monto,
monto: res[i].monto, hizoPago: res[i].hizoPago,
hizo_pago: res[i].hizoPago, fechaInscripcion: moment(res[i].fechaInscripcion).format('L'),
fecha_inscripcion: moment(res[i].fechaInscripcion).format('L'), validacion: res[i].validacion,
}); motivoDeclinacion: res[i].motivo,
} });
} else {
for (let i = 0; i < res.length; i++) {
data.push({
numeroCuenta: res[i].Usuario.numeroCuenta,
validacion: res[i].validacion,
confirmacion: res[i].confirmacion,
folio: res[i].folio,
monto: res[i].monto,
hizoPago: res[i].hizoPago,
fechaInscripcion: moment(res[i].fechaInscripcion).format('L'),
idArea: res[i].idArea,
});
}
} }
await helper.eliminarArchivo(path).catch((err) => {}); await helper.eliminarArchivo(path).catch((err) => {});
return helper.crearArchivo(path, convertArrayToCSV(data)); return helper.crearArchivo(path, convertArrayToCSV(data));
+9 -3
View File
@@ -1,15 +1,21 @@
const { validarNumeroEntero } = require('../../helper/validar');
const dbPath = '../../db/tablas'; const dbPath = '../../db/tablas';
const Usuario = require(`${dbPath}/Usuario`);
const Inscripcion = require(`${dbPath}/Inscripcion`); const Inscripcion = require(`${dbPath}/Inscripcion`);
const ticket = async (body) => { const ticket = async (body) => {
const folio = validarNumeroEntero(body.folio, 'folio', true);
return Inscripcion.findOne({ return Inscripcion.findOne({
where: { folio: body.folio }, where: { folio: body.folio },
attributes: ['rutaTicket', 'extension'], attributes: ['rutaTicket', 'extension', 'motivo'],
}) })
.then((res) => { .then((res) => {
if (!res) throw new Error('No pudimos encontrar este ticket.'); if (!res) throw new Error('No pudimos encontrar este ticket.');
return { rutaTicket: res.rutaTicket, extension: res.extension }; return {
rutaTicket: res.rutaTicket,
extension: res.extension,
motivo: res.motivo,
};
}) })
.catch((err) => { .catch((err) => {
throw new Error('No fue posible validar el ticket. ' + err); throw new Error('No fue posible validar el ticket. ' + err);
@@ -1,12 +1,13 @@
const validar = require('../../helper/validar'); const { validarNumeroEntero } = require('../../helper/validar');
const { Op } = require('sequelize'); const { Op } = require('sequelize');
const dbPath = '../../db/tablas'; const dbPath = '../../db/tablas';
const Usuario = require(`${dbPath}/Usuario`); const Usuario = require(`${dbPath}/Usuario`);
const Inscripcion = require(`${dbPath}/Inscripcion`); const Inscripcion = require(`${dbPath}/Inscripcion`);
const todasInscripciones = async (body) => { const todasInscripciones = async (body) => {
const validacion = validarNumeroEntero(body.validacion, 'validacion', true);
return Inscripcion.findAll({ return Inscripcion.findAll({
where: { validacion: body.validacion }, where: { validacion, cancelacion: 0 },
include: [ include: [
{ {
model: Usuario, model: Usuario,
+13 -18
View File
@@ -1,26 +1,21 @@
const dbPath = '../../db/tablas'; const dbPath = '../../db/tablas';
const Inscripcion = require(`${dbPath}/Inscripcion`); const Inscripcion = require(`${dbPath}/Inscripcion`);
const Usuario = require(`${dbPath}/Usuario`); const { validarNumeroEntero } = require('../../helper/helper');
const { usuarioInscrito } = require('../../config/mariadb.conf');
const validarSinTicket = async (body) => { const validarSinTicket = async (body) => {
return usuarioInscrito(body.numeroCuenta, 0) const idUsuario = validarNumeroEntero(body.idUsuario, 'usuario', true);
.then((res) => { return Inscripcion.update(
return Inscripcion.update( {
{ validacion: 1,
validacion: 1, },
}, {
{ where: {
where: { idUsuario,
idUsuario: body.idUsuario, },
validacion: 2, }
}, )
}
);
})
.then((res) => ({ .then((res) => ({
message: message: '¡El ticket a sido validado de forma correcta!',
'Tu inscripción está sujeta a validación, en caso de no ser correcta o veraz el servicio será suspendido.',
})) }))
.catch((err) => { .catch((err) => {
throw new Error('¡ No fue posible validar la inscripción !. '); throw new Error('¡ No fue posible validar la inscripción !. ');
+28 -21
View File
@@ -1,50 +1,57 @@
const { validarNumeroEntero } = require('../../helper/validar');
const dbPath = '../../db/tablas'; const dbPath = '../../db/tablas';
const Inscripcion = require(`${dbPath}/Inscripcion`); const Inscripcion = require(`${dbPath}/Inscripcion`);
const Usuario = require(`${dbPath}/Usuario`);
const { usuarioInscrito } = require('../../config/mariadb.conf');
const validarTicket = async (body) => { const validarTicket = async (body) => {
const validacion = validarNumeroEntero(body.validacion, 'validacion', true);
const folio = validarNumeroEntero(body.folio, 'folio', true);
return Inscripcion.findOne({ return Inscripcion.findOne({
where: { folio: body.folio }, where: { folio: body.folio },
}) })
.then((res) => { .then((res) => {
if (!res) throw new Error('Este folio no existe'); if (!res) throw new Error('Este folio no existe');
idUsuario = res.idUsuario; idUsuario = res.idUsuario;
return Inscripcion.findOne({ if (validacion == 1) {
where: { folio: body.folio, validacion: 1 }, return Inscripcion.findOne({
}); where: { folio, validacion: 1 },
});
}
}) })
.then((res) => { .then((res) => {
if (res) throw new Error('Este folio ya fue validado'); if (res) throw new Error('Este folio ya fue validado');
return Inscripcion.update( return Inscripcion.update(
{ {
validacion: body.validacion, validacion,
}, },
{ {
where: { where: {
folio: body.folio, folio,
validacion: 2,
}, },
} }
); );
}) })
.then((res) => { .then((res) => {
if (body.validacion === 0) if (body.validacion === 0) {
throw new Error( return Inscripcion.update(
'El administrador a declinado el ticket, ya que los datos no coinciden.' { motivo: body.motivo },
{
where: {
folio: body.folio,
},
}
); );
}
}) })
.then((res) => { .then((res) => {
return Usuario.findOne({ if (body.validacion === 1)
where: { idUsuario }, return {
attributes: ['numeroCuenta'], message: '¡El ticket a sido validado de forma correcta!',
}).then((res) => { };
return usuarioInscrito(res.numeroCuenta, 1).then(async (res) => { else
return { return {
message: El ticket a sido validado de forma correcta !', message: '¡El ticket a sido declinado',
}; };
});
});
}) })
.catch((err) => { .catch((err) => {
throw new Error('No fue posible validar el ticket. ' + err); throw new Error('No fue posible validar el ticket. ' + err);
+15 -12
View File
@@ -1,35 +1,38 @@
const { obtenerDatosUsr } = require('../../config/mariadb.conf');
const { const {
obtenerIdCarrera, validarNumeroCuenta,
obtenerCarrera, validarNumeroEntero,
} = require('../../config/mariadb.conf'); } = require('../../helper/validar');
const validar = require('../../helper/validar');
const dbPath = '../../db/tablas'; const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Usuario = require(`${dbPath}/Usuario`); const Usuario = require(`${dbPath}/Usuario`);
const escolares = async (body) => { const escolares = async (body) => {
const numeroCuenta = validarNumeroCuenta(
body.numeroCuenta,
'numero cuenta',
true
);
return Usuario.findOne({ return Usuario.findOne({
where: { numeroCuenta: body.numeroCuenta }, where: { numeroCuenta },
}).then((res) => { }).then((res) => {
if (!res) { if (!res) {
return obtenerIdCarrera(body.numeroCuenta).then(async (res) => { return obtenerDatosUsr(numeroCuenta).then(async (res) => {
return Usuario.create({ return Usuario.create({
idUsuario: body.idUsuario, numeroCuenta,
numeroCuenta: body.numeroCuenta,
nombre: body.nombre, nombre: body.nombre,
semestre: 8, generacion: res.generacion,
carrera: body.carrera, carrera: body.carrera,
idCarrera: res.id_carrera, idCarrera: res.id_carrera,
}); });
}); });
} }
return Usuario.findOne({ return Usuario.findOne({
where: { numeroCuenta: body.numeroCuenta }, where: { numeroCuenta },
attributes: [ attributes: [
'idUsuario', 'idUsuario',
'numeroCuenta', 'numeroCuenta',
'nombre', 'nombre',
'semestre', 'generacion',
'idCarrera', 'idCarrera',
'carrera', 'carrera',
], ],
@@ -2,7 +2,8 @@ const moment = require('moment');
const fs = require('fs'); const fs = require('fs');
const { validarNumeroEntero, validarNumero } = require('../../helper/validar'); const { validarNumeroEntero, validarNumero } = require('../../helper/validar');
const { eliminarArchivo } = require('../../helper/helper'); const { eliminarArchivo } = require('../../helper/helper');
const { usuarioInscrito } = require('../../config/mariadb.conf'); const gmail = require('../../helper/gmail');
const correoInscripciones = require('../../helper/correo');
const dbPath = '../../db/tablas'; const dbPath = '../../db/tablas';
const Inscripcion = require(`${dbPath}/Inscripcion`); const Inscripcion = require(`${dbPath}/Inscripcion`);
@@ -13,15 +14,20 @@ const inscripcion = async (body, file) => {
const monto = validarNumero(body.monto, 'monto', true); const monto = validarNumero(body.monto, 'monto', true);
const folio = body.folio; const folio = body.folio;
let correo = {};
let email = '';
return Inscripcion.findOne({ return Inscripcion.findOne({
where: { folio }, where: { folio, cancelacion: 0 },
}) })
.then((res) => { .then((res) => {
if (res) throw new Error('Este folio ya esta registrado'); if (res) throw new Error('Este folio ya esta registrado');
return Inscripcion.findOne({ return Inscripcion.findOne({
where: { idUsuario, idArea }, where: { idUsuario, idArea, cancelacion: 0 },
}).then((res) => { }).then((res) => {
if (res) throw new Error('Ya estas registrado en esta área'); if (res) throw new Error('Ya estas registrado en esta área');
email = `${body.numeroCuenta}@pcpuma.acatlan.unam.mx`;
correo = correoInscripciones();
if (file && folio && body.fechaTicket) { if (file && folio && body.fechaTicket) {
return Inscripcion.create({ return Inscripcion.create({
idUsuario, idUsuario,
@@ -47,10 +53,11 @@ const inscripcion = async (body, file) => {
.then((res) => { .then((res) => {
if (file) if (file)
fs.renameSync(file.path, file.path + '.' + file.mimetype.split('/')[1]); fs.renameSync(file.path, file.path + '.' + file.mimetype.split('/')[1]);
return gmail(correo.subject, email, correo.msj);
}) })
.then((res) => ({ .then((res) => ({
message: message:
'Tu inscripción está sujeta a validación, en caso de no ser correcta o veraz el servicio será suspendido.', 'Tu inscripción está sujeta a validación, en caso de no ser correcta o veraz el servicio será suspendido. Por favor revisa tu correo de PCPUMA para confirmar tu registro.',
})) }))
.catch((err) => { .catch((err) => {
if (file) eliminarArchivo(file.path); if (file) eliminarArchivo(file.path);
+5 -5
View File
@@ -1,19 +1,19 @@
const validar = require('../../helper/validar'); const { validarNumeroEntero } = require('../../helper/validar');
const dbPath = '../../db/tablas'; const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Inscripcion = require(`${dbPath}/Inscripcion`); const Inscripcion = require(`${dbPath}/Inscripcion`);
const inscripciones = async (body) => { const inscripciones = async (body) => {
const idUsuario = validarNumeroEntero(body.idUsuario, 'Usuario', true);
return Inscripcion.findAll({ return Inscripcion.findAll({
where: { idUsuario: body.idUsuario }, where: { idUsuario },
}).then((res) => { }).then((res) => {
if (!res) return []; if (!res) return [];
return Inscripcion.findAll({ return Inscripcion.findAll({
where: { idUsuario: body.idUsuario }, where: { idUsuario, cancelacion: 0 },
attributes: [ attributes: [
'idInscripcion', 'idInscripcion',
'validacion', 'validacion',
'confirmacion',
'folio', 'folio',
'monto', 'monto',
'idUsuario', 'idUsuario',
-1
View File
@@ -13,7 +13,6 @@ const login = async (body) => {
passwordUser: body.passwordUser, passwordUser: body.passwordUser,
}; };
console.log(numeroCuenta, body.passwordUser);
return axios return axios
.post( .post(
`https://venus.acatlan.unam.mx/conexionEscolares_test/ingresarAlumno`, `https://venus.acatlan.unam.mx/conexionEscolares_test/ingresarAlumno`,
-32
View File
@@ -1,32 +0,0 @@
const Usuario = require('./tablas/Usuario');
const { encriptar } = require('../helper/encriptar');
const dataUsuarios = async () => {
let usuario = ['416313221', '111111111', '222222222'];
let nombre = [
'Adriana De Luna Ramirez',
'Nombre Falso 1',
'Nombre Falso 2',
];
for (let i = 0; i < usuario.length; i++) {
await Usuario.create({
usuario: usuario[i],
nombre: nombre[i],
password: encriptar('holi'),
idTipoUsuario: 2,
});
console.log(`Se insertó el usuario ${usuario[i]}.`.magenta);
}
};
const exec = async () => {
await dataUsuarios();
console.log(
'\nSe ha instalado exitosamente la información falsa en la base de datos.\n'
.underline.bold.green
);
process.exit();
};
exec();
+6 -4
View File
@@ -18,16 +18,18 @@ Inscripcion.init(
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
defaultValue: 2, defaultValue: 2,
}, },
confirmacion: { cancelacion: {
type: DataTypes.BOOLEAN, type: DataTypes.BOOLEAN,
allowNull: false, defaultValue: 0,
defaultValue: false, },
motivo: {
type: DataTypes.STRING(100),
defaultValue: null,
}, },
folio: { folio: {
type: DataTypes.STRING(10), type: DataTypes.STRING(10),
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
unique: true,
}, },
monto: { monto: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
+2 -2
View File
@@ -22,8 +22,8 @@ Usuario.init(
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
}, },
semestre: { generacion: {
type: DataTypes.STRING(30), type: DataTypes.STRING(5),
allowNull: false, allowNull: false,
}, },
idCarrera: { idCarrera: {
+20
View File
@@ -0,0 +1,20 @@
const correoInscripciones = () => ({
subject: `Inscripción a CEDETEC`,
msj: `
<p>Estimado Usuario</p>
<p>
Su inscripción esta sujeta a revisión, es necesario revisar los datos que registro en el sistema.
</p>
<p>Te sugerimos guardar tu ticket para cualquier aclaración</p>
<p>Por el momento podras hacer tu confirmación en <a href="https://kalinga.acatlan.unam.mx/cedetec/" target="_blanc">KALINGA</a></p>
<p>En caso de recibir un correo con el asunto Inscripción declinada se cancelara el servicio y no podras hacer uso de los servicios</p>
<p>Atentamente:</p>
<p>Atención Usuarios DSC</p>
`,
});
module.exports = correoInscripciones;
+2 -3
View File
@@ -5,11 +5,10 @@ const send = require('gmail-send')({
pass: process.env.GMAILPASSWORD, pass: process.env.GMAILPASSWORD,
}); });
const gmail = (subject, to, text) => { const gmail = (subject, to, html) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
send({ subject, to, text }, (error, result, fullResult) => { send({ subject, to, html }, (error, result, fullResult) => {
if (error) reject(error); if (error) reject(error);
console.log(fullResult);
resolve(result); resolve(result);
}); });
}); });
+33 -1
View File
@@ -1,13 +1,15 @@
const express = require('express'); const express = require('express');
const app = express(); const app = express();
const fs = require('fs'); const fs = require('fs');
const { validarAlfanumerico } = require('../helper/validar');
const { verificaToken } = require('../middleware/autentificacion'); const { verificaToken } = require('../middleware/autentificacion');
const route = '/Admin'; const route = '/Admin';
const controllerPath = '../controller/Admin'; const controllerPath = '../controller/Admin';
const login = require(`${controllerPath}/login`); const login = require(`${controllerPath}/login`);
const todasInscripciones = require(`${controllerPath}/todasInscripciones`); const todasInscripciones = require(`${controllerPath}/todasInscripciones`);
const ticket = require(`${controllerPath}/ticket`); const ticket = require(`${controllerPath}/ticket`);
const actualizarTicket = require(`${controllerPath}/actualizarTicket`);
const cancelarInscripcion = require(`${controllerPath}/cancelarInscripcion`);
const motivo = require(`${controllerPath}/motivo`);
const validarSinTicket = require(`${controllerPath}/validarSinTicket`); const validarSinTicket = require(`${controllerPath}/validarSinTicket`);
const validarTicket = require(`${controllerPath}/validarTicket`); const validarTicket = require(`${controllerPath}/validarTicket`);
const reporte = require(`${controllerPath}/reporte`); const reporte = require(`${controllerPath}/reporte`);
@@ -45,6 +47,36 @@ app.get(`${route}/ticket`, (req, res) => {
}); });
}); });
app.get(`${route}/motivo`, verificaToken, (req, res) => {
return motivo(req.query)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
app.put(`${route}/actualizar_ticket`, verificaToken, (req, res) => {
return actualizarTicket(req.body)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
app.put(`${route}/cancelar_inscripcion`, verificaToken, (req, res) => {
return cancelarInscripcion(req.body)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
app.put(`${route}/validar`, verificaToken, (req, res) => { app.put(`${route}/validar`, verificaToken, (req, res) => {
return validarTicket(req.body) return validarTicket(req.body)
.then((data) => { .then((data) => {