is not empty

This commit is contained in:
xXpuma99Xx
2022-07-24 22:35:00 -05:00
parent 79996060ef
commit 254504f7a9
77 changed files with 511 additions and 301 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ export class AuthController {
})
@ApiBody({
description: 'Todas las variables son obligatorias.',
examples: { ejemplo: { value: { usuario: '', password: '' } } },
examples: { ejemplo: { value: { password: '', usuario: '' } } },
})
loginUsuario(@Body() body: LoginUsuarioDto) {
return this.authService.loginUsuario(body.usuario, body.password);
+5 -7
View File
@@ -1,5 +1,5 @@
import { ConfigService } from '@nestjs/config';
import { Module } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { AuthController } from './auth.controller';
@@ -15,12 +15,10 @@ import { UsuarioModule } from '../usuario/usuario.module';
BcryptModule,
JwtModule.registerAsync({
inject: [ConfigService],
useFactory: (configService: ConfigService) => {
return {
secret: configService.get<string>('AUTH_SECRETKEY'),
signOptions: { expiresIn: '2h' },
};
},
useFactory: (configService: ConfigService) => ({
secret: configService.get<string>('AUTH_SECRETKEY'),
signOptions: { expiresIn: '2h' },
}),
}),
ModuloModule,
OperadorModule,
+7
View File
@@ -44,6 +44,13 @@ export class AuthService {
.findByOperador(modulo.institucion, operador, false)
.then((operador) => {
this.validarLogin(operador, password);
if (
operador.institucion.id_institucion !==
modulo.institucion.id_institucion
)
throw new ConflictException(
'Este módulo no pertenece a tu institución, selecciona uno válido.',
);
const payload: JwtPayload = {
id_modulo: modulo.id_modulo,
+4 -1
View File
@@ -1,9 +1,12 @@
import { IsString } from 'class-validator';
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
export class LoginAdminDto {
@IsString()
@IsNotEmpty()
@MaxLength(40)
operador: string;
@IsString()
@IsNotEmpty()
password: string;
}
+4 -1
View File
@@ -1,12 +1,15 @@
import { IsInt, IsString } from 'class-validator';
import { IsInt, IsNotEmpty, IsString, MaxLength } from 'class-validator';
export class LoginOperadorDto {
@IsInt()
id_modulo: number;
@IsString()
@IsNotEmpty()
@MaxLength(40)
operador: string;
@IsString()
@IsNotEmpty()
password: string;
}
+3 -1
View File
@@ -1,9 +1,11 @@
import { IsString } from 'class-validator';
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
export class LoginUsuarioDto {
@IsString()
password: string;
@IsString()
@IsNotEmpty()
@MaxLength(10)
usuario: string;
}
+2 -2
View File
@@ -1,9 +1,9 @@
export class JwtPayload {
id_tipo_usuario: number;
id_modulo?: number;
id_operador?: number;
id_tipo_usuario: number;
id_usuario?: number;
}
+3 -3
View File
@@ -2,10 +2,10 @@ import { Expose, Type } from 'class-transformer';
import { OperadorOutputDto } from '../../../operador/dto/output/operador.dto';
export class AuthOperadorOutputDto {
@Expose()
token;
@Expose()
@Type(() => OperadorOutputDto)
operador;
@Expose()
token;
}