category
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { Controller, Get, Req, UseGuards } from '@nestjs/common';
|
||||
import { Controller, Get, Req, UseGuards, Patch, Body, ValidationPipe } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
||||
import { AuthGuard, type AuthRequest } from 'src/modules/auth/guards/auth.guard';
|
||||
import { UserService } from './user.service';
|
||||
// import { UpdateUserDto } from './dto/update-user.dto';
|
||||
import { UpdateUserDto } from './dto/update-user.dto';
|
||||
|
||||
@ApiTags('User')
|
||||
@Controller('user')
|
||||
@@ -24,22 +24,23 @@ export class UserController {
|
||||
restId,
|
||||
};
|
||||
}
|
||||
|
||||
// 2. Update User Specification (PATCH /user/spec)
|
||||
// @UseGuards(AuthGuard)
|
||||
// @ApiBearerAuth()
|
||||
// @ApiOperation({ summary: 'Update the user specification' })
|
||||
// @ApiBody({ type: UpdateUserDto })
|
||||
// @Patch('/')
|
||||
// async updateUserSpec(@Req() req: AuthRequest, @Body() dto: UpdateUserDto) {
|
||||
// const userId = req.user.sub;
|
||||
// const user = await this.userService.updateUser(userId, dto);
|
||||
// return {
|
||||
// message: `PATCH request: Updating specification for user ${userId} `,
|
||||
// userId,
|
||||
// user,
|
||||
// };
|
||||
// }
|
||||
// 2. Update User Specification (PATCH /user)
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Update the authenticated user profile' })
|
||||
@Patch('/')
|
||||
async updateUser(
|
||||
@Req() req: AuthRequest,
|
||||
@Body(new ValidationPipe({ transform: true, whitelist: true })) dto: UpdateUserDto,
|
||||
) {
|
||||
const userId = req.userId;
|
||||
const user = await this.userService.updateUser(userId, dto);
|
||||
return {
|
||||
message: `PATCH request: Updating profile for user ${userId}`,
|
||||
userId,
|
||||
user,
|
||||
};
|
||||
}
|
||||
|
||||
// @UseGuards(AdminAuthGuard)
|
||||
// @ApiBearerAuth()
|
||||
|
||||
Reference in New Issue
Block a user