-
Notifications
You must be signed in to change notification settings - Fork 4
♻️ refactor: 인증 payload 사용 방법 변경 #483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors authentication handling across controllers by replacing direct access to req.user with a custom @CurrentUser() decorator. This improves code consistency and type safety.
- Introduces a new
@CurrentUser()decorator to extract user information from requests - Replaces all instances of
@Req() reqwith@CurrentUser() user: Payloadacross controllers - Removes unnecessary
Number.parseInt()conversion in file controller
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| server/src/common/decorator/current-user.decorator.ts | Creates the new @CurrentUser() decorator that extracts user from request context |
| server/src/common/decorator/index.ts | Exports the current-user decorator for use across the application |
| server/src/user/controller/user.controller.ts | Replaces req.user with @CurrentUser() decorator in refresh token and update profile endpoints |
| server/src/like/controller/like.controller.ts | Replaces req.user with @CurrentUser() decorator in get, create, and delete like endpoints |
| server/src/like/service/like.service.ts | Updates get method signature to accept Payload | null for optional authentication |
| server/src/file/controller/file.controller.ts | Replaces req.user with @CurrentUser() decorator and removes unnecessary Number.parseInt() |
| server/src/comment/controller/comment.controller.ts | Replaces req.user with @CurrentUser() decorator in create, delete, and update comment endpoints |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot
AI
Oct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user.id is of type number according to the Payload type definition. However, the old code used Number.parseInt(req.user.id), suggesting that user.id might be a string at runtime. If user.id is actually a string in the JWT payload, this could cause a type mismatch when calling fileService.create() which expects a number. Verify that the JWT payload parsing correctly converts the ID to a number, or add explicit type conversion here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
📋 작업 내용
@CurrentUser데코레이터 작성기존에는
@Req req를 controller 메서드의 인자로 전달받아req.user형태로 사용했지만, payload의 타입과 의도를 명확하게 하기 위하여 별도 데코레이터를 생성하였습니다.동작 흐름을 간략화시 다음과 같이 진행됩니다.
사용자 인증
payload접근 방법 변경변경된 스펙에 맞게 기존에 존재하던 인증 엔드포인트들을 수정 하였습니다.