liberacion
This commit is contained in:
@@ -7,25 +7,23 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const registro = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let password = '';
|
||||
let correo = {};
|
||||
let idUsuario = null;
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
include: [{ model: Usuario }],
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res) throw new Error('No existe este servicio.');
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
|
||||
switch (res.idStatus) {
|
||||
case 1:
|
||||
let password = encriptar.generarPassword();
|
||||
let correo = correos.preRegistro(password, res.Usuario.nombre);
|
||||
|
||||
await gmail(correo.subject, res.correo, correo.msj);
|
||||
|
||||
return Usuario.update(
|
||||
{ password: encriptar.encriptar(password) },
|
||||
{ where: { idUsuario: res.idUsuario } }
|
||||
);
|
||||
password = encriptar.generarPassword();
|
||||
correo = correos.preRegistro(password, res.Usuario.nombre);
|
||||
idUsuario = res.idUsuario;
|
||||
return gmail(correo.subject, res.correo, correo.msj);
|
||||
case 2:
|
||||
throw new Error('Este Servicio Social ya se encuentra en Registro.');
|
||||
case 3:
|
||||
@@ -43,6 +41,12 @@ const registro = async (body) => {
|
||||
throw new Error('Este Servicio Social esta cancelado.');
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
return Usuario.update(
|
||||
{ password: encriptar.encriptar(password) },
|
||||
{ where: { idUsuario } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update({ idStatus: 2 }, { where: { idServicio } });
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user