correo
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const helperPath = '../../helper';
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const correoPcPuma = require(`${helperPath}/correo`);
|
||||
const encriptar = require(`${helperPath}/encriptar`);
|
||||
const gmail = require(`${helperPath}/gmail`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
@@ -12,15 +13,16 @@ const crear = async (body) => {
|
||||
);
|
||||
const telefono = validar.validarNumero(body.telefono, 'teléfono', true, 15);
|
||||
const password = encriptar.generarPassword();
|
||||
let correo = '';
|
||||
let correo = {};
|
||||
let email = '';
|
||||
|
||||
return Usuario.findOne({ where: { idUsuario } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este usuario.');
|
||||
if (res.password) throw new Error('Este usuario ya fue registrado.');
|
||||
if (!res.activo) throw new Error('Este usuario no esta activo.');
|
||||
// correo = `${res.usuario}@pcpuma.acatlan.unam.mx`;
|
||||
correo = 'lemuelhelonmarquezrosas@gmail.com';
|
||||
email = `${res.usuario}@pcpuma.acatlan.unam.mx`;
|
||||
correo = correoPcPuma(password);
|
||||
return Usuario.update(
|
||||
{
|
||||
password: encriptar.encriptar(password),
|
||||
@@ -29,8 +31,8 @@ const crear = async (body) => {
|
||||
{ where: { idUsuario } }
|
||||
);
|
||||
})
|
||||
.then((res) => gmail('Contraseña', correo, password))
|
||||
.then((res) => ({
|
||||
.then(() => gmail(correo.subject, email, correo.msj))
|
||||
.then(() => ({
|
||||
message:
|
||||
'Se creó correctamente tu cuenta, ingresa a tu correo @pcpuma para consultar tu contraseña para este servicio.',
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user