From c2595d919d9311b068d7a48dbf1b2c287792f915 Mon Sep 17 00:00:00 2001 From: Traym17 <51390112+Traym17@users.noreply.github.com> Date: Sun, 10 Jul 2022 20:46:54 -0600 Subject: [PATCH] =?UTF-8?q?Validaci=C3=B3n=20de=20correo=20y=20contrase?= =?UTF-8?q?=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/users/users.controller.ts | 3 ++- servicio-usuarios/src/users/users.service.ts | 27 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/servicio-usuarios/src/users/users.controller.ts b/servicio-usuarios/src/users/users.controller.ts index 2d7539da..bbdaa2df 100644 --- a/servicio-usuarios/src/users/users.controller.ts +++ b/servicio-usuarios/src/users/users.controller.ts @@ -43,6 +43,7 @@ export class UsersController { @MessagePattern({ cmd: 'loginUser' }) findLogin(@Payload() body:string) { let pemail= body['email']; - return this.userService.findLogin(pemail); + let ppassword= body['password']; + return this.userService.findHero(pemail,ppassword); } } diff --git a/servicio-usuarios/src/users/users.service.ts b/servicio-usuarios/src/users/users.service.ts index 5e2d9381..ea04a239 100644 --- a/servicio-usuarios/src/users/users.service.ts +++ b/servicio-usuarios/src/users/users.service.ts @@ -39,7 +39,30 @@ export class UsersService { } //inicio de sesion - async findLogin(email: string): Promise { - return this.userModel.findOne({ email:email}).exec(); + async findLogin(email: string, password: string): Promise { + return this.userModel.findOne({ email:email},{ password:password}).exec(); + } + + async findHero(email: string, password: string) : Promise { + let repo1=this.userModel; + let p = new Promise((resolve, reject) => { + let repo =repo1; + + repo.find({ email : email }).exec((err, res) => { + if (err) { + reject(err); + } + else { + if (res[0].password==password) { + resolve(res[0]); + } + else { + resolve(null); + } + } + }); + }); + + return p; } }