modified update user
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
import { Body, Controller, Get, Patch, Post, UseGuards } from '@nestjs/common';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
NotFoundException,
|
||||
Patch,
|
||||
Post,
|
||||
Req,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { AuthService } from './auth.service';
|
||||
import { CreateUsuarioDto } from 'src/usuarios/dto/create-usuario.dto';
|
||||
import { LoginDto } from './dto/login.dto';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { UpdateUsuarioDto } from 'src/usuarios/dto/update-usuario.dto';
|
||||
import { not } from 'rxjs/internal/util/not';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
@@ -23,8 +33,14 @@ export class AuthController {
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Patch('update')
|
||||
update(@Body() registroDto: UpdateUsuarioDto) {
|
||||
return this.authService.update(registroDto);
|
||||
update(@Body() registroDto: UpdateUsuarioDto, @Req() req: any) {
|
||||
const id_usuario = req.user.id;
|
||||
|
||||
if (!id_usuario) {
|
||||
throw new NotFoundException('token sin id_usuario');
|
||||
}
|
||||
|
||||
return this.authService.update(registroDto,id_usuario);
|
||||
}
|
||||
|
||||
@Post('login')
|
||||
|
||||
Reference in New Issue
Block a user