From c1106e7d63f3f827882cfba7e2cdb7380882c020 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sat, 20 Aug 2022 19:50:41 -0600 Subject: [PATCH] format --- servicio-usuarios/src/users/users.service.ts | 39 ++++++++++---------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/servicio-usuarios/src/users/users.service.ts b/servicio-usuarios/src/users/users.service.ts index b2c42794..dc2549d2 100644 --- a/servicio-usuarios/src/users/users.service.ts +++ b/servicio-usuarios/src/users/users.service.ts @@ -14,8 +14,8 @@ export class UsersService { @InjectModel(User.name) private readonly userModel: Model, @Inject('SERVICIO_NOTIFICACIONES') private readonly clientNotificationtApp: ClientProxy, @Inject('SERVICIO_COMUNIDADES') private readonly clientCommunityApp: ClientProxy, - ) { } + private publicKey: string; async create(user: UserDocument): Promise { let passwordEncriptada = Md5.init(user.password); @@ -78,14 +78,14 @@ export class UsersService { }); } - /* async remove(id: string) { - return this.userModel.findByIdAndRemove({ _id: id }).exec(); - }*/ + /* async remove(id: string) { + return this.userModel.findByIdAndRemove({ _id: id }).exec(); + }*/ async remove(id: string) { - return this.userModel.findOneAndUpdate({ _id: id }, {status: '-1'}, { + return this.userModel.findOneAndUpdate({ _id: id }, { status: '-1' }, { new: true, - }); + }); } //inicio de sesion @@ -100,12 +100,13 @@ export class UsersService { } else { let passwordEncriptada = Md5.init(password); if (res.length > 0) { - if (res[0].password == passwordEncriptada) { - resolve(res[0]); + if (res[0].password == passwordEncriptada) { + resolve(res[0]); + } else { + resolve(null); + } } else { resolve(null); - }}else{ - resolve(null); } } }); @@ -183,16 +184,16 @@ export class UsersService { } async deleteAdminSystem(id: string) { - return this.userModel.findOneAndUpdate({ _id: id }, {status: '-1'}, { + return this.userModel.findOneAndUpdate({ _id: id }, { status: '-1' }, { new: true, - }); + }); } deleteAdminCommunity(id: string) { - return this.userModel.findOneAndUpdate({ _id: id }, {status: '-1'}, { + return this.userModel.findOneAndUpdate({ _id: id }, { status: '-1' }, { new: true, - }); + }); } async validateEmail(email: string) { @@ -226,17 +227,17 @@ export class UsersService { const houses = response['houses']; let num_house = ""; await houses.forEach(async house => { - if (tenant_id == house.tenants.tenant_id) { - num_house = house.number_house; - } + if (tenant_id == house.tenants.tenant_id) { + num_house = house.number_house; + } }) return num_house; } async changeStatus(id: string, status: string) { - return this.userModel.findOneAndUpdate({ _id: id }, {status: status}, { + return this.userModel.findOneAndUpdate({ _id: id }, { status: status }, { new: true, - }); + }); } }