token y cambios al reporte

This commit is contained in:
Andres2908
2022-02-22 16:31:40 -06:00
parent 34a741bd41
commit 0a9ae79747
9 changed files with 58 additions and 35 deletions
-1
View File
@@ -27,7 +27,6 @@ const escolares = async (body) => {
}
return Usuario.findOne({
where: { numeroCuenta: body.numeroCuenta },
// include: [{ model: Carrera }],
attributes: [
'idUsuario',
'numeroCuenta',
+7 -1
View File
@@ -1,8 +1,8 @@
const validar = require('../../helper/validar');
const escolares = require('./escolares');
const axios = require('axios');
const { crearToken } = require('../../middleware/autentificacion');
const Usuario = require('../../db/tablas/Usuario');
const { comparar } = require('../../helper/encriptar');
const login = async (body) => {
const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
@@ -24,6 +24,12 @@ const login = async (body) => {
const datos = escolares(info.data);
return datos;
})
.then((res) => ({
Usuario: res,
token: crearToken({
idUsuario: numeroCuenta,
}),
}))
.catch((err) => {
throw new Error('Usuario o contraseña incorrecta.');
});