actually call the correct function

This commit is contained in:
Eduardo Quiros 2022-09-01 02:59:41 -06:00
parent da8c57e369
commit 030cc74b5f
No known key found for this signature in database
GPG Key ID: B77F36C3F12720B4
3 changed files with 22 additions and 9 deletions

View File

@ -248,7 +248,7 @@ export class AppController {
@Body('community_id') community_id: string, @Body('community_id') community_id: string,
@Body('number_house') number_house: string, @Body('number_house') number_house: string,
) { ) {
return this.appService.updateUser( return this.appService.resetUserPassword(
id, id,
dni, dni,
name, name,

View File

@ -255,14 +255,27 @@ export class AppService {
.pipe(map((message: string) => ({ message }))); .pipe(map((message: string) => ({ message })));
} }
resetUserPassword(id: string, dni: string, name: string, last_name: string, email: string, phone: number resetUserPassword(
, user_type: string, status: string, date_entry: Date, community_id: string) { 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 pattern = { cmd: 'resetUserPassword' };
const payload = { const payload = {
id: id, dni: dni, name: name, last_name: last_name, email: email, phone: phone, 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 return this.clientUserApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(

View File

@ -73,15 +73,15 @@ export class UsersService {
} }
async resetUserPassword(user: UserDocument) { async resetUserPassword(user: UserDocument) {
const password = user.password; const unencryptedPassword = user.password;
const passwordEncriptada = Md5.init(password); const passwordEncriptada = Md5.init(user.password);
user.password = passwordEncriptada; user.password = passwordEncriptada;
this.userModel.findOneAndUpdate({ _id: user._id }, { password: passwordEncriptada }, { this.userModel.findOneAndUpdate({ _id: user._id }, user, {
new: true, new: true,
}); });
const pattern = { cmd: 'emailResetUserPassword' }; const pattern = { cmd: 'emailResetUserPassword' };
const payload = { const payload = {
email: user['email'], password: user['password'], email: user['email'], password: unencryptedPassword,
date_entry: user['date_entry'], community_name: user['community_id'] date_entry: user['date_entry'], community_name: user['community_id']
}; };
return this.clientNotificationtApp return this.clientNotificationtApp