Cambios el charly
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
|
||||
@Injectable()
|
||||
export class JwtAuthGuard extends AuthGuard('jwt'){}
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user