You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tryFullStack/backend/src/users/users.controller.ts

27 lines
1.1 KiB

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