Files
pcpuma_unam_api/src/auth/auth.controller.ts
T

68 lines
1.8 KiB
TypeScript
Raw Normal View History

2022-04-21 20:33:05 -05:00
import { Body, Controller, Post } from '@nestjs/common';
2022-05-30 15:22:31 -05:00
import { ApiBody, ApiOperation, ApiTags } from '@nestjs/swagger';
2022-04-21 20:33:05 -05:00
import { AuthService } from './auth.service';
2022-05-02 12:45:12 -05:00
import { AuthLoginAdminDto } from './dto/auth-login-admin.dto';
2022-04-21 20:33:05 -05:00
import { AuthLoginOperadorDto } from './dto/auth-login-operador.dto';
import { AuthLoginUsuarioDto } from './dto/auth-login-usuario.dto';
2022-04-21 16:31:26 -05:00
@Controller('auth')
2022-04-30 21:18:19 -05:00
@ApiTags('auth')
2022-04-21 20:33:05 -05:00
export class AuthController {
constructor(private authService: AuthService) {}
2022-05-02 12:45:12 -05:00
@Post('login-admin')
2022-05-30 15:22:31 -05:00
@ApiOperation({
description: 'Endpoint utilizado para el login del panel admin.',
})
@ApiBody({
description: 'Todas las variables son obligatorias.',
examples: {
ejemplo: {
value: {
operador: '',
password: '',
},
},
},
})
2022-05-02 12:45:12 -05:00
loginAdmin(@Body() body: AuthLoginAdminDto) {
return this.authService.loginAdmin(body.operador, body.password);
}
@Post('login-operador')
2022-05-30 15:22:31 -05:00
@ApiOperation({
description: 'Endpoint utilizado para el login del panel del operador.',
})
@ApiBody({
description: 'Todas las variables son obligatorias.',
examples: {
ejemplo: {
value: {
operador: '',
password: '',
id_modulo: 1,
},
},
},
})
2022-04-21 20:33:05 -05:00
loginOperador(@Body() body: AuthLoginOperadorDto) {
2022-04-21 21:52:40 -05:00
return this.authService.loginOperador(
2022-05-02 12:45:12 -05:00
body.id_modulo,
2022-04-21 21:52:40 -05:00
body.operador,
body.password,
);
2022-04-21 20:33:05 -05:00
}
2022-05-02 12:45:12 -05:00
@Post('login-usuario')
2022-06-13 05:33:53 -05:00
@ApiOperation({
description: 'Endpoint utilizado para el login del usuario.',
})
2022-05-30 15:22:31 -05:00
@ApiBody({
description: 'Todas las variables son obligatorias.',
examples: { ejemplo: { value: { usuario: '', password: '' } } },
})
2022-04-21 20:33:05 -05:00
loginUsuario(@Body() body: AuthLoginUsuarioDto) {
return this.authService.loginUsuario(body.usuario, body.password);
}
}