diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index 2b5fa6e3..69cd13eb 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -248,7 +248,7 @@ export class AppController { @Body('community_id') community_id: string, @Body('number_house') number_house: string, ) { - return this.appService.updateUser( + return this.appService.resetUserPassword( id, dni, name, diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 4e947f9e..d6fc1aff 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -176,7 +176,7 @@ export class AppService { .pipe(map((message: string) => ({ message }))); } - + async updateTenant( _id: string, dni: string, @@ -255,14 +255,27 @@ export class AppService { .pipe(map((message: string) => ({ message }))); } - resetUserPassword(id: string, dni: string, name: string, last_name: string, email: string, phone: number - , user_type: string, status: string, date_entry: Date, community_id: string) { + resetUserPassword( + id: string, + dni: string, + name: string, + last_name: string, + email: string, + phone: number, + _password: string, + user_type: string, + status: string, + date_entry: Date, + community_id: string, + number_house: string, + ) { const pattern = { cmd: 'resetUserPassword' }; const payload = { id: id, dni: dni, name: name, last_name: last_name, email: email, phone: phone, - password: this.generatePassword(), user_type: user_type, status: status, date_entry: date_entry, community_id + password: this.generatePassword(), user_type: user_type, status: status, date_entry: date_entry, community_id: community_id, number_house: number_house }; + console.log(payload); return this.clientUserApp .send(pattern, payload) .pipe( diff --git a/servicio-usuarios/src/users/users.service.ts b/servicio-usuarios/src/users/users.service.ts index f074c01d..9629f22a 100644 --- a/servicio-usuarios/src/users/users.service.ts +++ b/servicio-usuarios/src/users/users.service.ts @@ -73,15 +73,15 @@ export class UsersService { } async resetUserPassword(user: UserDocument) { - const password = user.password; - const passwordEncriptada = Md5.init(password); + const unencryptedPassword = user.password; + const passwordEncriptada = Md5.init(user.password); user.password = passwordEncriptada; - this.userModel.findOneAndUpdate({ _id: user._id }, { password: passwordEncriptada }, { + this.userModel.findOneAndUpdate({ _id: user._id }, user, { new: true, }); const pattern = { cmd: 'emailResetUserPassword' }; const payload = { - email: user['email'], password: user['password'], + email: user['email'], password: unencryptedPassword, date_entry: user['date_entry'], community_name: user['community_id'] }; return this.clientNotificationtApp