Primera prueba inicio
This commit is contained in:
parent
690dceb0e2
commit
b8034a875c
|
@ -5,7 +5,6 @@
|
|||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "api-gateway",
|
||||
"version": "0.0.1",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "katoikia-app",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
|
@ -5,7 +5,6 @@
|
|||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "servicio-usuarios",
|
||||
"version": "0.0.1",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue