diff --git a/servicio-notificaciones/src/email.controller.ts b/servicio-notificaciones/src/email.controller.ts index 0259684e..2f2d8c8d 100644 --- a/servicio-notificaciones/src/email.controller.ts +++ b/servicio-notificaciones/src/email.controller.ts @@ -6,18 +6,18 @@ import { User } from './user/user.entity'; @Controller() export class EmailController { - constructor(private mailService: MailerService) {} + constructor(private mailService: MailerService) { } - @MessagePattern({ cmd: 'sendMail' }) - sendMail(@Payload() toEmail: string) { - var response = this.mailService.sendMail({ - to: toEmail['email'], - from: 'katoikiap4@gmail.com', - subject: 'Plain Text Email ✔', - text: 'Welcome NestJS Email Sending Tutorial', - }); - return response; - } + @MessagePattern({ cmd: 'sendMail' }) + sendMail(@Payload() toEmail: string) { + var response = this.mailService.sendMail({ + to: toEmail['email'], + from: 'katoikiap4@gmail.com', + subject: 'Plain Text Email ✔', + text: 'Welcome NestJS Email Sending Tutorial', + }); + return response; + } @MessagePattern({ cmd: 'html' }) async postHTMLEmail(@Payload() user: any) { @@ -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; + } } diff --git a/servicio-notificaciones/src/mails/emailResetUserPassword.hbs b/servicio-notificaciones/src/mails/emailResetUserPassword.hbs new file mode 100644 index 00000000..2f454d42 --- /dev/null +++ b/servicio-notificaciones/src/mails/emailResetUserPassword.hbs @@ -0,0 +1,451 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌  +
+
+ + + + + + + + + + + + + + +
+ + + + + + +
+
+ Logo Katoikia +
+ + + + +
+
+

Fue asignado en la comunidad "{{community_name}}" en la vivienda #{{number_house}}

+ +
+
+

Estas son sus credenciales:

+

Correo electronico: {{email}}

+

Password: {{password}}

+ +
+
+

Ahora puede ingresar con sus credenciales en la app móvil

+
+
+
+ + + + + + + +
+

katoikiaapp.org

+
+ +
+
+ + + diff --git a/servicio-usuarios/src/users/users.service.ts b/servicio-usuarios/src/users/users.service.ts index fcd50326..5df15e3a 100644 --- a/servicio-usuarios/src/users/users.service.ts +++ b/servicio-usuarios/src/users/users.service.ts @@ -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(pattern, payload) + .pipe( + map((message: string) => ({ message })) + ); } async findCommunity(community_id: string) { @@ -306,8 +317,8 @@ export class UsersService { async removeIdCommunity(community_id: string){ await this.userModel.updateMany({community_id: community_id, user_type:'2' }, {"$set":{"community_id": ''}}); - await this.userModel.updateMany({community_id: community_id, user_type:'3' }, {"$set":{"community_id": '', "status": '-1'}}); - return this.userModel.updateMany({community_id: community_id, user_type:'4' }, {"$set":{"community_id": '', "status": '-1'}}); + await this.userModel.updateMany({community_id: community_id, user_type:'3' }, {"$set":{"community_id": '', "status": '-1'} }); + return this.userModel.updateMany({ community_id: community_id, user_type: '4' }, { "$set": { "community_id": '', "status": '-1' } }); } }