token y cambios al reporte
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const { crearToken } = require('../../middleware/autentificacion');
|
||||
const Admin = require('../../db/tablas/Admin');
|
||||
const { comparar } = require('../../helper/encriptar');
|
||||
|
||||
@@ -12,14 +13,21 @@ const login = async (body) => {
|
||||
|
||||
return Admin.findOne({
|
||||
where: { usuario: body.usuario },
|
||||
}).then((res) => {
|
||||
if (!comparar(password, res.password))
|
||||
throw new Error('La contraseña es incorrecta.');
|
||||
return Admin.findOne({
|
||||
where: { usuario: body.usuario },
|
||||
attributes: ['usuario'],
|
||||
});
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
if (!comparar(password, res.password))
|
||||
throw new Error('La contraseña es incorrecta.');
|
||||
return Admin.findOne({
|
||||
where: { usuario: body.usuario },
|
||||
attributes: ['usuario'],
|
||||
});
|
||||
})
|
||||
.then((res) => ({
|
||||
Usuario: res,
|
||||
token: crearToken({
|
||||
idUsuario: numeroCuenta,
|
||||
}),
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = login;
|
||||
|
||||
@@ -29,13 +29,15 @@ const reporte = async (body) => {
|
||||
],
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (body.tipo) {
|
||||
if (body.tipo === 'CSV') {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
data.push({
|
||||
numeroCuenta: res[i].Usuario.numeroCuenta,
|
||||
idArea: res[i].idArea,
|
||||
hizoPago: res[i].hizoPago,
|
||||
fechaInscripcion: moment(res[i].fechaInscripcion).format('L'),
|
||||
numero_cuenta: res[i].Usuario.numeroCuenta,
|
||||
id_area: res[i].idArea,
|
||||
folio: res[i].folio,
|
||||
monto: res[i].monto,
|
||||
hizo_pago: res[i].hizoPago,
|
||||
fecha_inscripcion: moment(res[i].fechaInscripcion).format('L'),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -46,6 +48,7 @@ const reporte = async (body) => {
|
||||
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,
|
||||
});
|
||||
|
||||
@@ -22,7 +22,9 @@ const validarTicket = async (body) => {
|
||||
.then((res) => {
|
||||
console.log(body.validacion);
|
||||
if (body.validacion === 0)
|
||||
throw new Error('El administrador a declinado el ticket');
|
||||
throw new Error(
|
||||
'El administrador a declinado el ticket, ya que los datos no coinciden.'
|
||||
);
|
||||
})
|
||||
.then((res) => ({
|
||||
message: '¡ El ticket a sido validado de forma correcta !',
|
||||
|
||||
Reference in New Issue
Block a user