|
5 | 5 | Controller, |
6 | 6 | Delete, |
7 | 7 | Get, |
| 8 | + Param, |
8 | 9 | ParseIntPipe, |
| 10 | + ParseUUIDPipe, |
9 | 11 | Patch, |
10 | 12 | Post, |
11 | 13 | Query, |
@@ -33,13 +35,15 @@ import { GetUser } from 'src/auth/decorator/getUser.decorator'; |
33 | 35 | import { UserGuard } from 'src/auth/guard/auth.guard'; |
34 | 36 |
|
35 | 37 | import { |
| 38 | + ChangePasskeyNameDto, |
36 | 39 | ChangePasswordDto, |
37 | 40 | DeleteUserReqDto, |
38 | 41 | IssueUserSecretDto, |
39 | 42 | RegisterDto, |
40 | 43 | VerifyPasskeyRegistrationDto, |
41 | 44 | } from './dto/req.dto'; |
42 | 45 | import { |
| 46 | + BasicPasskeyDto, |
43 | 47 | PasskeyRegisterOptionResDto, |
44 | 48 | UpdateUserPictureResDto, |
45 | 49 | UserConsentListResDto, |
@@ -187,38 +191,101 @@ export class UserController { |
187 | 191 | return this.userService.deleteUserPicture(user.uuid); |
188 | 192 | } |
189 | 193 |
|
| 194 | + @ApiOperation({ |
| 195 | + summary: 'get the passkey list of user', |
| 196 | + description: '사용자의 패스키 목록을 불러옵니다', |
| 197 | + }) |
| 198 | + @ApiBearerAuth('user:jwt') |
| 199 | + @ApiOkResponse({ |
| 200 | + description: 'success', |
| 201 | + type: [BasicPasskeyDto], |
| 202 | + }) |
| 203 | + @ApiUnauthorizedResponse({ description: 'token not valid' }) |
| 204 | + @ApiInternalServerErrorResponse({ description: 'server error' }) |
| 205 | + @UseGuards(UserGuard) |
| 206 | + @Get('passkey') |
| 207 | + async getPasskeyList(@GetUser() user: User): Promise<BasicPasskeyDto[]> { |
| 208 | + return await this.userService.getPasskeyList(user.uuid); |
| 209 | + } |
| 210 | + |
190 | 211 | @ApiOperation({ |
191 | 212 | summary: 'register the passkey', |
192 | 213 | description: '패스키를 등록을 위한 challenge를 발급합니다.', |
193 | 214 | }) |
| 215 | + @ApiBearerAuth('user:jwt') |
194 | 216 | @ApiOkResponse({ |
195 | 217 | description: 'success', |
196 | 218 | type: PasskeyRegisterOptionResDto, |
197 | 219 | }) |
| 220 | + @ApiUnauthorizedResponse({ description: 'token not valid' }) |
198 | 221 | @ApiNotFoundResponse({ description: 'Email is not found' }) |
199 | 222 | @ApiInternalServerErrorResponse({ description: 'server error' }) |
| 223 | + @UseGuards(UserGuard) |
200 | 224 | @Post('passkey') |
201 | 225 | async registerOptions( |
202 | | - @Body() { email }: IssueUserSecretDto, |
| 226 | + @GetUser() user: User, |
203 | 227 | ): Promise<PasskeyRegisterOptionResDto> { |
204 | | - return await this.userService.registerOptions(email); |
| 228 | + return await this.userService.registerOptions(user.email); |
205 | 229 | } |
206 | 230 |
|
207 | 231 | @ApiOperation({ |
208 | 232 | summary: 'verify the registration options', |
209 | 233 | description: '패스키 등록합니다.', |
210 | 234 | }) |
| 235 | + @ApiBearerAuth('user:jwt') |
211 | 236 | @ApiOkResponse({ description: 'success', type: Boolean }) |
212 | | - @ApiUnauthorizedResponse({ description: 'Response is invalid' }) |
| 237 | + @ApiUnauthorizedResponse({ description: 'token not valid' }) |
213 | 238 | @ApiNotFoundResponse({ description: 'Email is not found' }) |
214 | 239 | @ApiInternalServerErrorResponse({ description: 'server error' }) |
| 240 | + @UseGuards(UserGuard) |
215 | 241 | @Post('passkey/verify') |
216 | 242 | async verifyRegistration( |
217 | | - @Body() { email, registrationResponse }: VerifyPasskeyRegistrationDto, |
| 243 | + @GetUser() user: User, |
| 244 | + @Body() { name, registrationResponse }: VerifyPasskeyRegistrationDto, |
218 | 245 | ): Promise<boolean> { |
219 | 246 | return await this.userService.verifyRegistration( |
220 | | - email, |
| 247 | + user.email, |
| 248 | + name, |
221 | 249 | registrationResponse, |
222 | 250 | ); |
223 | 251 | } |
| 252 | + |
| 253 | + @ApiOperation({ |
| 254 | + summary: 'update name of passkey', |
| 255 | + description: '패스키의 이름을 수정합니다.', |
| 256 | + }) |
| 257 | + @ApiBearerAuth('user:jwt') |
| 258 | + @ApiOkResponse({ description: 'success', type: BasicPasskeyDto }) |
| 259 | + @ApiUnauthorizedResponse({ description: 'token not valid' }) |
| 260 | + @ApiForbiddenResponse({ description: 'Invalid user or token' }) |
| 261 | + @ApiNotFoundResponse({ description: 'Id is not found' }) |
| 262 | + @ApiInternalServerErrorResponse({ description: 'server error' }) |
| 263 | + @UseGuards(UserGuard) |
| 264 | + @Patch('passkey/:id') |
| 265 | + async updatePasskey( |
| 266 | + @GetUser() user: User, |
| 267 | + @Param('id', ParseUUIDPipe) id: string, |
| 268 | + @Body() { name }: ChangePasskeyNameDto, |
| 269 | + ): Promise<BasicPasskeyDto> { |
| 270 | + return await this.userService.updatePasskey(id, name, user.uuid); |
| 271 | + } |
| 272 | + |
| 273 | + @ApiOperation({ |
| 274 | + summary: 'delete passkey', |
| 275 | + description: '패스키를 삭제합니다.', |
| 276 | + }) |
| 277 | + @ApiBearerAuth('user:jwt') |
| 278 | + @ApiOkResponse({ description: 'success' }) |
| 279 | + @ApiUnauthorizedResponse({ description: 'token not valid' }) |
| 280 | + @ApiForbiddenResponse({ description: 'Invalid user or token' }) |
| 281 | + @ApiNotFoundResponse({ description: 'Id is not found' }) |
| 282 | + @ApiInternalServerErrorResponse({ description: 'server error' }) |
| 283 | + @UseGuards(UserGuard) |
| 284 | + @Delete('passkey/:id') |
| 285 | + async deletePasskey( |
| 286 | + @GetUser() user: User, |
| 287 | + @Param('id', ParseUUIDPipe) id: string, |
| 288 | + ): Promise<void> { |
| 289 | + return await this.userService.deletePasskey(id, user.uuid); |
| 290 | + } |
224 | 291 | } |
0 commit comments