From d3c179eae481b23eb0a06bd37c9c3143a38df8ed Mon Sep 17 00:00:00 2001 From: Drakthor475 Date: Tue, 21 Oct 2025 15:29:44 -0600 Subject: [PATCH] Cambios el charly --- src/auth/auth.guard.ts | 6 ------ src/auth/auth.module.ts | 7 +++---- src/usuarios/usuarios.controller.ts | 20 +++++--------------- src/usuarios/usuarios.service.ts | 7 ++----- 4 files changed, 10 insertions(+), 30 deletions(-) delete mode 100644 src/auth/auth.guard.ts diff --git a/src/auth/auth.guard.ts b/src/auth/auth.guard.ts deleted file mode 100644 index 92b15a9..0000000 --- a/src/auth/auth.guard.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { AuthGuard } from '@nestjs/passport'; - -@Injectable() -export class JwtAuthGuard extends AuthGuard('jwt'){} - diff --git a/src/auth/auth.module.ts b/src/auth/auth.module.ts index f9f1d3a..e762eb7 100644 --- a/src/auth/auth.module.ts +++ b/src/auth/auth.module.ts @@ -3,13 +3,12 @@ import { AuthController } from './auth.controller'; import { AuthService } from './auth.service'; import { UsuariosModule } from 'src/usuarios/usuarios.module'; import { JwtModule } from '@nestjs/jwt'; -import { PassportModule } from '@nestjs/passport'; -import { JwtStrategy } from './jwt.strategy'; + + @Module({ imports:[UsuariosModule, JwtModule, - PassportModule, JwtModule.register({ global:true, secret: process.env.JWT, @@ -18,6 +17,6 @@ import { JwtStrategy } from './jwt.strategy'; }), ], controllers: [AuthController], - providers: [AuthService,JwtStrategy] + providers: [AuthService] }) export class AuthModule {} diff --git a/src/usuarios/usuarios.controller.ts b/src/usuarios/usuarios.controller.ts index 14e6681..889edfd 100644 --- a/src/usuarios/usuarios.controller.ts +++ b/src/usuarios/usuarios.controller.ts @@ -1,7 +1,8 @@ -import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; +import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common'; import { UsuariosService } from './usuarios.service'; import { CreateUsuarioDto } from './dto/create-usuario.dto'; import { UpdateUsuarioDto } from './dto/update-usuario.dto'; +import { AuthGuard } from '@nestjs/passport'; @Controller('usuarios') export class UsuariosController { @@ -13,22 +14,11 @@ export class UsuariosController { } @Get() + @UseGuards(AuthGuard("jwt")) findAll() { return this.usuariosService.findAll(); } - @Get(':id') - findOne(@Param('id') id: string) { - return this.usuariosService.findOne(+id); - } - - @Patch(':id') - update(@Param('id') id: string, @Body() updateUsuarioDto: UpdateUsuarioDto) { - return this.usuariosService.update(+id, updateUsuarioDto); - } - - @Delete(':id') - remove(@Param('id') id: string) { - return this.usuariosService.remove(+id); - } + + } diff --git a/src/usuarios/usuarios.service.ts b/src/usuarios/usuarios.service.ts index ec482ea..27094fb 100644 --- a/src/usuarios/usuarios.service.ts +++ b/src/usuarios/usuarios.service.ts @@ -1,6 +1,5 @@ import { Injectable } from '@nestjs/common'; import { CreateUsuarioDto } from './dto/create-usuario.dto'; -import { UpdateUsuarioDto } from './dto/update-usuario.dto'; import { InjectRepository } from '@nestjs/typeorm'; import { Usuario } from './entities/usuario.entity'; import { Repository } from 'typeorm'; @@ -33,14 +32,12 @@ export class UsuariosService { findAll() { - return `This action returns all usuarios`; + return this.usuarioRepository.find(); } - update(id: number, updateUsuarioDto: UpdateUsuarioDto) { - return `This action updates a #${id} usuario`; - } + }