login,registro y auth funcionando

This commit is contained in:
Your Name
2025-06-16 10:24:03 -06:00
parent e39a148adc
commit c8ce8f0dfb
3 changed files with 26 additions and 7 deletions
+4
View File
@@ -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()
+12 -6
View File
@@ -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' })
+10 -1
View File
@@ -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