agregar funciones para enviar correo con nueva contraseña
This commit is contained in:
parent
f065a0418b
commit
4556aaba98
|
@ -112,4 +112,37 @@ export class EmailController {
|
||||||
});
|
});
|
||||||
return response;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,11 +73,22 @@ export class UsersService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async resetUserPassword(user: UserDocument) {
|
async resetUserPassword(user: UserDocument) {
|
||||||
let passwordEncriptada = Md5.init(user.password);
|
const password = user.password;
|
||||||
|
const passwordEncriptada = Md5.init(password);
|
||||||
user.password = passwordEncriptada;
|
user.password = passwordEncriptada;
|
||||||
return this.userModel.findOneAndUpdate({ _id: user._id }, { password: passwordEncriptada }, {
|
this.userModel.findOneAndUpdate({ _id: user._id }, { password: passwordEncriptada }, {
|
||||||
new: true,
|
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) {
|
async findCommunity(community_id: string) {
|
||||||
|
|
Loading…
Reference in New Issue