Primera prueba inicio

This commit is contained in:
Traym17 2022-07-10 20:22:34 -06:00
parent 690dceb0e2
commit b8034a875c
7 changed files with 36 additions and 2 deletions

View File

@ -5,7 +5,6 @@
"requires": true,
"packages": {
"": {
"name": "api-gateway",
"version": "0.0.1",
"license": "UNLICENSED",
"dependencies": {

View File

@ -44,6 +44,14 @@ export class AppController {
return this.appService.allUsers();
}
@Post('user/loginUser')
inicioSesion(
@Body('email') pEmail: string,
@Body('password') pPassword: string,
) {
return this.appService.inicioSesion(pEmail,pPassword);
}
@Get('user/find/:dni')
findUser(
@Param('dni') paramUserDNI: string

View File

@ -71,6 +71,16 @@ export class AppService {
);
}
inicioSesion(pEmail: string, pPassword: string) {
const pattern = { cmd: 'loginUser' };
const payload = { email: pEmail, password: pPassword};
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
// ====================== COMMUNITIES ===============================
//POST parameter from API

6
package-lock.json generated Normal file
View File

@ -0,0 +1,6 @@
{
"name": "katoikia-app",
"lockfileVersion": 2,
"requires": true,
"packages": {}
}

View File

@ -5,7 +5,6 @@
"requires": true,
"packages": {
"": {
"name": "servicio-usuarios",
"version": "0.0.1",
"license": "UNLICENSED",
"dependencies": {

View File

@ -38,4 +38,11 @@ export class UsersController {
let dni = id['dni'];
return this.userService.remove(dni);
}
//inicio de sesion
@MessagePattern({ cmd: 'loginUser' })
findLogin(@Payload() body:string) {
let pemail= body['email'];
return this.userService.findLogin(pemail);
}
}

View File

@ -37,4 +37,9 @@ export class UsersService {
async remove(id: string) {
return this.userModel.findByIdAndRemove({ _id: id }).exec();
}
//inicio de sesion
async findLogin(email: string): Promise<User> {
return this.userModel.findOne({ email:email}).exec();
}
}