Skip to content

[FEAT] 9주차 미션_맹덕 - #43

Open
YONGJAEEE wants to merge 1 commit into
mengduckfrom
week9-mengduck
Open

[FEAT] 9주차 미션_맹덕#43
YONGJAEEE wants to merge 1 commit into
mengduckfrom
week9-mengduck

Conversation

@YONGJAEEE

@YONGJAEEE YONGJAEEE commented May 26, 2026

Copy link
Copy Markdown
Contributor

🛠️ 작업 사항

  • JWT 구현, 인증 방식 Stateless로 변경
  • 로그인 API 구현

📸 관련 이미지 (스크린샷 또는 동영상)

스크린샷 2026-05-26 19 38 27 스크린샷 2026-05-26 19 40 20

💬 기타 설명

💡 추가적으로 공유할 내용이나 리뷰어에게 전달할 사항이 있다면 작성해 주세요.

@YONGJAEEE YONGJAEEE changed the title [FEAT] 로그인 API 구현, JWT를 통한 Stateless 인증 구현 [FEAT] 9주차 미션_맹덕 May 26, 2026
@@ -0,0 +1,6 @@
package org.example.umc10thyongjae.domain.auth.dto.response;

public record LoginResponseDto(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맹덕이는 로그인 결과 반환으로 accessToken만 반환하도록 설계 했구나. 나는 acccessToken에다가 userId까지 반환하도록 설계를 했어. 프론트에서 로그인한뒤 바로 마이페이지로 보내는 것 같은 상황을 생각해보면 유저식별자가 필요할거라고 생각했기 때문이야. 스터디때 서로 의견 한번 얘기해보면 좋겠다

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userId 도 필요하면 내려주고~ 무엇보다 만료시간은 웬만하면 같이 내려주는게 좋아 맹덕!

return user.getId();
}

@Transactional(readOnly = true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로그인 서비스에서는 DB작업을 조회만 하니까 readOnly=true로 선언해주는거 되게 좋은것 같다. 나도 반영해봐야지

return;
}
// Bearer이면 추출
token = token.replace("Bearer ", "");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서 toen.replace를 사용하면 문자열 안에 있는 Bearer이 모두 삭제되기 때문에 혹시 모를 상황을 대비해 token.substring(7,token.length())를 이용해서 앞의 7글자만 제거하는 방식도 있더라

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 되게 신박한 생각이네 ...
엄청 낮은 확률로 나올 에러겠지만 발생하면 원인을 아예 못찾겠다

반영해볼게 땡큐!!

@gyeonseo gyeonseo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맹덕 9주차도 무난하게 잘 해줬군!! 좋다 항상 미션도 뻔하지 않게 맹덕만의 방식으로 해주고.. 맹덕도 워낙 잘해서 데모데이 걱정이 안되네~ 이상한 남자분 조심하고 데모데이도 좋은 팀 만나서 재밌게 개발해봤으면 좋겠다 9주차 미션도 수고많았어 맹덕덕!

public enum GeneralErrorCode implements BaseErrorCode {
BAD_REQUEST(HttpStatus.BAD_REQUEST, "BAD_REQUEST", "잘못된 요청입니다. "),
UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "UNAUTHORIZED", "인증되지 않았습니다."),
LOGIN_UNAVAILABLE(HttpStatus.UNAUTHORIZED, "LOGIN_UNAVAILABLE", "아이디 또는 비밀번호가 일치하지 않습니다."),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines 23 to +30
@PostMapping("/signUp")
public ApiResponse<SignUpResponseDto> signUp(
public ApiResponse<Void> signUp(
@RequestBody @Valid SignUpRequestDto dto
) {
Long userId = authService.signUp(dto);

return ApiResponse.onSuccess(GeneralSuccessCode.OK, new SignUpResponseDto(userId));
return ApiResponse.onSuccess(GeneralSuccessCode.OK, null);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

회원가입 응답을 Void로 둘지, userId 같은 식별자를 내려줄지는 다음 클라이언트 플로우 기준도 생각해보면 좋을듯!

예를 들어 가입 직후 로그인 화면으로 보내는 구조라면 Void도 충분하고,
가입 직후 온보딩/프로필 설정으로 이어지는 구조라면 userId나 accessToken 같은 응답이 필요할 수도 있겠지?

서비스에서 userId를 반환하는데 컨트롤러에서 반환하지 않도록 바꿔줘서 한번 얘기해본다!

@@ -0,0 +1,6 @@
package org.example.umc10thyongjae.domain.auth.dto.response;

public record LoginResponseDto(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userId 도 필요하면 내려주고~ 무엇보다 만료시간은 웬만하면 같이 내려주는게 좋아 맹덕!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants