-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/mission 09/워니 #69
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
base: 워니/main
Are you sure you want to change the base?
The head ref may contain hidden characters: "feature/mission-09/\uC6CC\uB2C8"
Conversation
- error.js: 에러 클래스 status code 추가 - review.service.js: 커스텀 에러 구현 - userMission.service.js: 미션 유효성 검사 구현 Resolve: #52
- Swagger doc에 공통 스키마 추가 Resolve: #52
- 모든 API에서 동일한 형태로 문서화, 각 API별로 에러 예시만 example로 바꿈 - 성공 응답: 각 API에서 example로 실제 데이터 보여줌 Resolve: #52
- Swagger responses 예시 수정 - $ref 위치 수정 - example 오버라이드 구조 정리 - content -> application/json 형태로 맞춤 Resolve: #52
- Google Login 인증 키 발급 완료 - 성공 응답 확인 Resolve: #62
- 변경된 OpenAPI 3.x 표준에 맞는 구조로 변경 Resolve: #62
- 내 정보 수정용 API 추가 - JWT 인증 미들웨어 src/middlewares/auth.middleware.js 추가 - JWT 기존 API에 추가(가게 추가, 리뷰 작성, 미션 등록, 미션 도전, 미션 완료 처리) Resolve: #62
jeongkyueun
left a comment
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.
구글 로그인 구현하시고 JWT 미들웨어 추가 잘 하신 거 같습니다 수고 많으셨습니다!!
soyun0318
left a comment
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.
에러 처리를 진짜 꼼꼼하게 잘 작성하신 것 같아요!
KateteDeveloper
left a comment
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.
JWT를 너무 잘 구현해주신 것 같습니다! 수고 많으셨습니다~!
suyeon0421
left a comment
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.
authMiddleward로 따로 파일 작성해서 구현한 방법 가독성도 좋고 너무 좋은 것 같아요!! 수고하셨습니다!!
hyeeon
left a comment
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.
미션 모두 잘 구현해주신 것 같아요! 수고 많으셨어요!!
Hminkyung
left a comment
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.
9주차 미션 수행하느라 너무 고생많으셨어요!! 서비스랑 레이어 구조도 명확하고 DTO 레이어에서 검증 하신것 너무 좋습니다! 마지막 배포 미션까지 힘내봅시다!! 화이팅!!
| */ | ||
|
|
||
| const missionId = Number(req.params.mission_id); | ||
| const userId = Number(req.body.user_id); |
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.
JWT 인증에서는 로그인한 사용자만 본인의 userId 로 접근한다 ! 가 핵심 포인트입니다! 근데 여기에서는 user_id를 body에서 입력 받고 있기 때문에 누구나 다른 유저로 미션 도전이 가능한 이슈가 발생하고 있어요! 즉, 내가 로그인이 되어있떠라도 user_id에 다른 유저의 아이디를 입력하면 입력된 유저의 미션을 도전 가능한 상태가 되어버리는거죠!
따라서 이 경우에는 authMiddleware에서 만든 req.user.id 를 사용해야 해요!
const userId = req.user.id;
| } | ||
| */ | ||
|
|
||
| const userId = Number(req.params.user_id); |
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.
마찬가지로 진행 중인 미션 조회도 아무나 조회가 가능한 이슈가 발생하고 있기 때문에 외부 입력을 그대로 사용하지 말고 JWT 인증이 적용이 되고 있기 때문에 JWT 기반으로 /users/me/missions 등의 엔드포인트로 변경하거나
if (req.user.id !== userId) {
return res.status(403).json({});
}
이런식으로 권한 체크를 해주면 됩니다!
| if (!body.password || typeof body.password !== "string") { | ||
| throw new Error("password는 필수이며 문자열이어야 합니다."); | ||
| } | ||
|
|
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.
회원가입 DTO에서의 필수값과 Swagger에서의 필수값이 동일하지 않아요!!
Swagger에서는 email, pw, name 이 요구되는데 여기서는 nickname, phonenumber도 필수로 요구되고 있어요!! 둘이 통일되어야해요!
Chapter_mission/src/auth.config.js
Outdated
| data: { | ||
| email, | ||
| password: "GOOGLE_OAUTH_USER", | ||
| // 선택 필드들 |
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.
하드코딩도 직관적이고 너무 좋지만 실질적으로 createdUser가 생성이 되면 모든 google 로그인 유저가 같은 이름, 닉네임, 번호로 생성이 됩니다! 그 이후를 고려했을 때 phoneNumber나 birth 같은건 null, 빈배열 등으로 두고 /users/me에서 수정하는 식으로 유도해도 좋아요!
- 기능별 route 파일 분리 - users.route.js 추가 - stores.route.js 추가 - missions.route.js 추가 - index.js prefix 설정 Resolve: #62
- mission, review, store, userMission DTO 변환시 검증 로직 추가 - user.dto에는 검증 로직 존재하므로 추후 필요시 수정 Resolve: #62
- <auth.config.js> - 기존 하드코딩 수정: Google OAuth 신규 가입시 모든 정보 하드코딩 되었던 부분 -> email, name, profileImage만 저장 - 기존 하드코딩 수정: nickname(google_랜덤값 자동생성), phoneNumber(null, 사용자가 직접 수정), gender(UNKNOWN), birth(null) - payload.id(String) → userId(BigInt) 수정 - <user.controller.js> - /users/me API에 “Google로 온 사용자는 꼭 nickname/phoneNumber/birth 업데이트하도록” 가이드 메시지 추가 - <index.js, auth.routes.js> - Swagger에서 Google OAuth 신규가입 응답 스키마 자동화 Resolve: #62
- Prisma schema, DTO, Swagger에서 요구되는 필수값 일치하게 수정 Resolve: #62
🚀 작업한 기능 설명 (Feature Description)
🔍 작업 상세 (Implementation Details)
8주차 피드백
정보 수정 API 추가
JWT 기존 API에 추가
🖼️ 이미지 첨부 (Images)
📋 관련 자료 (Related Resources)
📝 추가 정보 (Additional Information)