|
|
|
import { Body, Controller, Patch, Request, UseGuards } from '@nestjs/common';
|
|
|
|
import { UsersService } from './users.service';
|
|
|
|
import { ChangePasswordDto } from './dto/change-password.dto';
|
|
|
|
import { JwtAuthGuard } from 'src/auth/jwt-auth.guard';
|
|
|
|
import { AuthRequest } from 'src/common/interfaces/auth-request.interface';
|
|
|
|
import { ApiBearerAuth, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
|
|
import { UserInfoResponseDto } from './dto/user-info-response.dto';
|
|
|
|
|
|
|
|
@ApiTags('사용자')
|
|
|
|
@Controller('users')
|
|
|
|
export class UsersController {
|
|
|
|
constructor(private readonly userService: UsersService) {}
|
|
|
|
|
|
|
|
@Patch('password')
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
|
|
@ApiBearerAuth()
|
|
|
|
@ApiOperation({ summary: '비밀번호 변경' })
|
|
|
|
@ApiOkResponse({ description: '성공', type: UserInfoResponseDto })
|
|
|
|
async changePassword(
|
|
|
|
@Request() req: AuthRequest,
|
|
|
|
@Body() dto: ChangePasswordDto,
|
|
|
|
): Promise<UserInfoResponseDto> {
|
|
|
|
await this.userService.changePassword(req.user.userId, dto);
|
|
|
|
return await this.userService.findUserInfoByIdOrFail(req.user.userId);
|
|
|
|
}
|
|
|
|
}
|