Files
pcpuma_acatlan_api/server/controller/Usuario/usuario.js
T

29 lines
759 B
JavaScript
Raw Normal View History

const { Op } = require('sequelize');
2021-04-28 00:21:24 -05:00
const validar = require('../../helper/validar');
2021-05-03 23:38:03 -05:00
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const TipoUsuario = require(`${dbPath}/TipoUsuario`);
2021-09-20 00:22:04 -05:00
const Usuario = require(`${dbPath}/Usuario`);
2021-04-28 00:21:24 -05:00
2021-05-04 00:32:04 -05:00
const usuario = async (body) => {
2021-04-28 00:21:24 -05:00
const usuario = validar.validarNumeroCuenta(body.usuario);
return Usuario.findOne({
where: { usuario, password: { [Op.ne]: null } },
2021-04-28 00:21:24 -05:00
include: [{ model: TipoUsuario }, { model: Carrera }],
2022-01-20 22:01:14 -06:00
attributes: [
'idUsuario',
'usuario',
'nombre',
'telefono',
'multa',
'activo',
],
2021-04-28 00:21:24 -05:00
}).then((res) => {
if (!res) throw new Error('No existe este usuario.');
return res;
});
};
2021-05-04 00:32:04 -05:00
module.exports = usuario;