diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 7324fc6..f092d3f 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -4,6 +4,7 @@ import { AuthService } from './auth.service'; import { LoginDto } from './dto/login.dto'; import { AuthGuard } from '@nestjs/passport'; import { RegisterDto } from './dto/register.dto'; +import { ApiBearerAuth } from '@nestjs/swagger'; @Controller() export class AuthController { @@ -16,6 +17,9 @@ export class AuthController { return this.authService.login(user); } + + @UseGuards(AuthGuard('jwt')) + @ApiBearerAuth('bearer') @UseGuards(AuthGuard('jwt')) @Get('profile') @AuthDocumentation.bearerAuth() diff --git a/src/entities/entities.ts b/src/entities/entities.ts index 4f8d4c5..8add556 100644 --- a/src/entities/entities.ts +++ b/src/entities/entities.ts @@ -47,8 +47,14 @@ export class Usuario { @PrimaryGeneratedColumn({ name: 'id_usuario', type: 'int' }) id_usuario: number; - @Column({ type: 'varchar', length: 9 }) - num_cuenta: string; + @Column({ + type: 'varchar', + length: 9, + unique: true, + nullable: true, + default: null, + }) + num_cuenta: string; @Column({ type: 'varchar', length: 60 }) nombre: string; @@ -66,11 +72,11 @@ export class Usuario { default: null, }) rfc: string | null; - @Column({ name: 'fecha_nacimiento', type: 'varchar', length: 8 }) - fecha_nacimiento: string; + @Column({ name: 'fecha_nacimiento', type: 'varchar', nullable: true, length: 8 }) + fecha_nacimiento: string | null; - @Column({ type: 'int' }) - generacion: number; + @Column({ type: 'int', nullable: true, }) + generacion: number | null; @ManyToOne(() => Genero, genero => genero.usuarios, { nullable: true }) @JoinColumn({ name: 'id_genero' }) diff --git a/src/main.ts b/src/main.ts index 5871d92..96bd98b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -22,7 +22,16 @@ async function bootstrap() { 'El objetivo es mejorar la gestion interna y la integridad de los datos', ) .setVersion('1.0') - .addBearerAuth() + .addBearerAuth( + { + type: 'http', + scheme: 'bearer', + bearerFormat: 'JWT', + name: 'Authorization', + in: 'header', + }, + 'bearer', // nombre del security definition + ) .build(); // .addServer(process.env.SWAGGER_SERVER_URL) // descomentar parael servidor de acatlan