Mensajes y corregí errores en el login

This commit is contained in:
Andres2908
2022-01-30 23:50:17 -06:00
parent 494e7380f3
commit f591727f82
6 changed files with 30 additions and 14 deletions
+14 -7
View File
@@ -1,4 +1,7 @@
const { obtenerAlumno, obtenerCarrera } = require('../../config/mariadb.conf');
const {
obtenerIdCarrera,
obtenerCarrera,
} = require('../../config/mariadb.conf');
const validar = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
@@ -11,12 +14,15 @@ const escolares = async (body) => {
where: { numeroCuenta: body.numeroCuenta },
}).then((res) => {
if (!res) {
return Usuario.create({
idUsuario: body.idUsuario,
numeroCuenta: body.numeroCuenta,
nombre: body.nombre,
semestre: 8,
carrera: body.carrera,
return obtenerIdCarrera(body.numeroCuenta).then(async (res) => {
return Usuario.create({
idUsuario: body.idUsuario,
numeroCuenta: body.numeroCuenta,
nombre: body.nombre,
semestre: 8,
carrera: body.carrera,
idCarrera: res.id_carrera,
});
});
}
return Usuario.findOne({
@@ -27,6 +33,7 @@ const escolares = async (body) => {
'numeroCuenta',
'nombre',
'semestre',
'idCarrera',
'carrera',
],
});
@@ -21,7 +21,9 @@ const inscripcion = async (body) => {
fechaIncripcion: ahora.format(),
fechaTicket: body.fechaTicket,
idFechaInscripcion: body.idFechaInscripcion,
});
}).then((res) => ({
message: '¡La inscripción se realizo de manera correcta!',
}));
};
module.exports = inscripcion;
+2 -1
View File
@@ -8,7 +8,8 @@ const inscripciones = async (body) => {
return Inscripcion.findOne({
where: { idUsuario: body.idUsuario },
}).then((res) => {
if (!res) return;
console.log(res);
if (!res) return [];
return Inscripcion.findAll({
where: { idUsuario: body.idUsuario },
attributes: [
+3 -1
View File
@@ -18,12 +18,14 @@ const login = async (body) => {
)
.then((res) => {
const info = res.data;
console.log('res.data');
// console.log(res.data);
info.data.numeroCuenta = numeroCuenta;
const datos = escolares(info.data);
return datos;
})
.catch((err) => {
console.log(err);
throw new Error('Usuario o contraseña incorrecta.' + err);
});
};