Merge branch 'master' of https://repositorio.acatlan.unam.mx/CIDWA/pcpuma_acatlan_api into dev
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Multa = require(`${dbPath}/Multa`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const multar = async (body) => {
|
||||
const idUsuario = validar.validarNumeroEntero(
|
||||
body.idUsuario,
|
||||
'id usuario',
|
||||
true
|
||||
);
|
||||
|
||||
return Usuario.findOne({ where: { idUsuario } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este usuario.');
|
||||
return Multa.findAll({ where: { idUsuario, activo: true } });
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.length > 2)
|
||||
throw new Error(
|
||||
'El usuario tiene más de 2 multas activas, favor de notificar a un operador sobre este problema.'
|
||||
);
|
||||
return res;
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = multar;
|
||||
@@ -94,7 +94,6 @@ const historial = async (body) => {
|
||||
],
|
||||
limit: 25,
|
||||
offset: 25 * (pagina - 1),
|
||||
order: [['createdAt', 'DESC']],
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@ Multa.init(
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
},
|
||||
activo: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
const Equipo = require('../db/tablas/Equipo');
|
||||
|
||||
Equipo.update({ prestado: false });
|
||||
@@ -13,7 +13,7 @@ const verificaToken = (req, res, next) => {
|
||||
let message = '';
|
||||
|
||||
if (err.message === 'invalid signature')
|
||||
message = 'El token no es valido. Inicia sesión de nuevo.';
|
||||
message = 'Se termino el tiempo de tu sesión. Inicia sesión de nuevo.';
|
||||
if (err.message === 'jwt expired')
|
||||
message = 'El token expiro. Inicia sesión de nuevo.';
|
||||
if (err.message === 'jwt malformed')
|
||||
|
||||
+4
-4
@@ -8,10 +8,10 @@ module.exports = {
|
||||
origin: [
|
||||
// 'http://localhost:3046',
|
||||
// 'http://localhost:3056',
|
||||
'http://132.248.80.196:3045',
|
||||
'http://132.248.80.196:3055',
|
||||
// 'https://pcpuma.acatlan.unam.mx',
|
||||
// 'https://pcpuma.acatlan.unam.mx:8080',
|
||||
// 'http://132.248.80.196:3045',
|
||||
// 'http://132.248.80.196:3055',
|
||||
'https://pcpuma.acatlan.unam.mx',
|
||||
'https://pcpuma.acatlan.unam.mx:8080',
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user