agregar funciones para enviar correo con nueva contraseña

This commit is contained in:
Eduardo Quiros 2022-08-23 22:27:26 -06:00
parent f065a0418b
commit 4556aaba98
No known key found for this signature in database
GPG Key ID: B77F36C3F12720B4
2 changed files with 59 additions and 15 deletions

View File

@ -112,4 +112,37 @@ export class EmailController {
});
return response;
}
@MessagePattern({ cmd: 'emailResetUserPassword' })
async emailResetUserPassword(@Payload() user: any) {
const url = "http://localhost:3000/";
const image = "images/email.png";
const logo = "images/Logo Katoikia.png";
let response = await this.mailService.sendMail({
to: user["email"],
from: "katoikiap4@gmail.com",
subject: 'Restablecer contraseña',
template: 'emailResetUserPassword',
context: {
name: user["name"],
password: user["password"],
date_entry: user["date_entry"],
email: user["email"],
community_name: user['community_name'],
number_house: user['number_house'],
},
attachments: [
{
filename: 'email.png',
path: __dirname + '/mails/images/email.png',
cid: 'image_email'
},
{
filename: 'Logo_Katoikia.png',
path: __dirname + '/mails/images/Logo_Katoikia.png',
cid: 'logoKatoikia'
}],
});
return response;
}
}

View File

@ -73,11 +73,22 @@ export class UsersService {
}
async resetUserPassword(user: UserDocument) {
let passwordEncriptada = Md5.init(user.password);
const password = user.password;
const passwordEncriptada = Md5.init(password);
user.password = passwordEncriptada;
return this.userModel.findOneAndUpdate({ _id: user._id }, { password: passwordEncriptada }, {
this.userModel.findOneAndUpdate({ _id: user._id }, { password: passwordEncriptada }, {
new: true,
});
const pattern = { cmd: 'emailResetUserPassword' };
const payload = {
email: user['email'], password: user['password'],
date_entry: user['date_entry'], community_name: user['community_id']
};
return this.clientNotificationtApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message }))
);
}
async findCommunity(community_id: string) {