const { Op } = require('sequelize'); const validar = require('../../helper/validar'); const dbPath = '../../db/tablas'; const Usuario = require(`${dbPath}/Usuario`); const Carrera = require(`${dbPath}/Carrera`); const TipoUsuario = require(`${dbPath}/TipoUsuario`); const usuario = async (body) => { const usuario = validar.validarNumeroCuenta(body.usuario); return Usuario.findOne({ where: { usuario, password: { [Op.ne]: null } }, include: [{ model: TipoUsuario }, { model: Carrera }], }).then((res) => { if (!res) throw new Error('No existe este usuario.'); delete res.dataValues.password; delete res.dataValues.idTipoUsuario; if (!res.idCarrera) delete res.dataValues.Carrera; delete res.dataValues.idCarrera; return res; }); }; module.exports = usuario;