update
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { Controller, Get, Patch, Body, Req, UseGuards, Query, ValidationPipe } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation, ApiBody } from '@nestjs/swagger';
|
||||
import { Controller, Get, Req, UseGuards, Query, 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';
|
||||
import { FindUsersDto } from './dto/find-user.dto';
|
||||
import { AdminAuthGuard } from 'src/modules/auth/guards/auth.admin.guard';
|
||||
|
||||
@@ -17,7 +17,7 @@ export class UserController {
|
||||
@Get('/')
|
||||
async getUser(@Req() req: AuthRequest) {
|
||||
const userId = req.user.sub;
|
||||
const user = await this.userService.findById(+userId);
|
||||
const user = await this.userService.findById(userId);
|
||||
return {
|
||||
message: `GET request: Retrieving profile for authenticated user `,
|
||||
user,
|
||||
@@ -25,20 +25,20 @@ export class UserController {
|
||||
}
|
||||
|
||||
// 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,
|
||||
};
|
||||
}
|
||||
// @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,
|
||||
// };
|
||||
// }
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
|
||||
Reference in New Issue
Block a user