Merge branch 'Lino' of https://repositorio.acatlan.unam.mx/IO/api-AT into Lino
This commit is contained in:
@@ -6,11 +6,13 @@ import {
|
||||
UseGuards,
|
||||
Request,
|
||||
Res,
|
||||
Req,
|
||||
} from '@nestjs/common';
|
||||
import type { Response } from 'express';
|
||||
import { UserService } from './user.service';
|
||||
import { CreateUserDto, Login } from './dto/create-user.dto';
|
||||
import { changePasswordDto, CreateUserDto, Login } from './dto/create-user.dto';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { JwtAuthGuard } from './jwt.guard';
|
||||
|
||||
@Controller('user')
|
||||
export class UserController {
|
||||
@@ -23,7 +25,7 @@ export class UserController {
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('/validate-token')
|
||||
getProfile(@Request() req) {
|
||||
getProfile(@Req() req) {
|
||||
return req.user;
|
||||
}
|
||||
|
||||
@@ -31,5 +33,13 @@ export class UserController {
|
||||
async createUser(@Body() data: CreateUserDto) {
|
||||
return this.userService.create(data);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/change-password')
|
||||
async changePassword(@Body() data: changePasswordDto, @Req() req) {
|
||||
const id_usuario = req.user.id;
|
||||
await this.userService.changePassword(data, id_usuario);
|
||||
return { message: 'Contraseña actualizada correctamente' };
|
||||
}
|
||||
}
|
||||
//IO
|
||||
|
||||
Reference in New Issue
Block a user