From 10b94b80badbb5b8c1f1cfb104337557df18a58c Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Thu, 27 Feb 2025 22:55:23 +0900 Subject: [PATCH 1/9] =?UTF-8?q?refactor:=20=EA=B2=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=EA=B4=80=EB=A0=A8=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=84=B0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/swyp8team2/auth/application/AuthService.java | 6 +++--- .../com/swyp8team2/auth/presentation/AuthController.java | 4 ++-- .../swyp8team2/auth/presentation/AuthControllerTest.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/swyp8team2/auth/application/AuthService.java b/src/main/java/com/swyp8team2/auth/application/AuthService.java index 470816d7..bbce4488 100644 --- a/src/main/java/com/swyp8team2/auth/application/AuthService.java +++ b/src/main/java/com/swyp8team2/auth/application/AuthService.java @@ -13,8 +13,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.security.NoSuchAlgorithmException; - @Service @RequiredArgsConstructor public class AuthService { @@ -40,11 +38,13 @@ private SocialAccount createUser(OAuthUserInfo oAuthUserInfo) { return socialAccountRepository.save(SocialAccount.create(userId, oAuthUserInfo)); } + @Transactional public TokenPair reissue(String refreshToken) { return jwtService.reissue(refreshToken); } - public String guestLogin() { + @Transactional + public String createGuestToken() { Long guestId = userService.createGuest(); return cryptoService.encrypt(String.valueOf(guestId)); } diff --git a/src/main/java/com/swyp8team2/auth/presentation/AuthController.java b/src/main/java/com/swyp8team2/auth/presentation/AuthController.java index b14bd9c2..2bbeaa44 100644 --- a/src/main/java/com/swyp8team2/auth/presentation/AuthController.java +++ b/src/main/java/com/swyp8team2/auth/presentation/AuthController.java @@ -56,8 +56,8 @@ public ResponseEntity reissue( } @PostMapping("/guest/token") - public ResponseEntity guestLogin() { - String guestToken = authService.guestLogin(); + public ResponseEntity guestToken() { + String guestToken = authService.createGuestToken(); return ResponseEntity.ok(new GuestTokenResponse(guestToken)); } } diff --git a/src/test/java/com/swyp8team2/auth/presentation/AuthControllerTest.java b/src/test/java/com/swyp8team2/auth/presentation/AuthControllerTest.java index 676f8231..4fb50574 100644 --- a/src/test/java/com/swyp8team2/auth/presentation/AuthControllerTest.java +++ b/src/test/java/com/swyp8team2/auth/presentation/AuthControllerTest.java @@ -150,10 +150,10 @@ void reissue_refreshTokenMismatched() throws Exception { @Test @DisplayName("게스트 토큰 발급") - void guestLogin() throws Exception { + void guestToken() throws Exception { //given String guestToken = "guestToken"; - given(authService.guestLogin()) + given(authService.createGuestToken()) .willReturn(guestToken); //when then From 813ea232dfdb61805f53211864964150d6fc2722 Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Thu, 27 Feb 2025 22:55:37 +0900 Subject: [PATCH 2/9] =?UTF-8?q?docs:=20=EA=B2=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=EB=B0=9C=EA=B8=89=20api=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/auth.adoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/docs/asciidoc/auth.adoc b/src/docs/asciidoc/auth.adoc index 04449d60..683a2657 100644 --- a/src/docs/asciidoc/auth.adoc +++ b/src/docs/asciidoc/auth.adoc @@ -10,3 +10,8 @@ operation::auth-controller-test/kakao-o-auth-sign-in[snippets='http-request,curl === `POST` 토큰 재발급 operation::auth-controller-test/reissue[snippets='http-request,curl-request,request-cookies,http-response,response-cookies,response-fields'] + +[[게스트-토큰-발급]] +=== `POST` 게스트 토큰 발급 + +operation::auth-controller-test/guest-token[snippets='http-request,curl-request,http-response,response-fields'] From a94201aa1f401ca31c0ae28ef5e81dd9cc0042a0 Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Thu, 27 Feb 2025 23:03:44 +0900 Subject: [PATCH 3/9] =?UTF-8?q?feat:=20=EB=8C=93=EA=B8=80=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comment/application/CommentService.java | 14 ++++++++------ .../comment/presentation/CommentController.java | 3 +-- .../presentation/dto/CommentResponse.java | 16 +++++++++------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/swyp8team2/comment/application/CommentService.java b/src/main/java/com/swyp8team2/comment/application/CommentService.java index ad46dd31..49d72c30 100644 --- a/src/main/java/com/swyp8team2/comment/application/CommentService.java +++ b/src/main/java/com/swyp8team2/comment/application/CommentService.java @@ -32,14 +32,16 @@ public void createComment(Long postId, CreateCommentRequest request, UserInfo us commentRepository.save(comment); } - public CursorBasePaginatedResponse findComments(Long postId, Long cursor, int size) { - Slice commentSlice = commentRepository.findByPostId(postId, cursor, PageRequest.of(0, size)); - return CursorBasePaginatedResponse.of(commentSlice.map(this::createCommentResponse)); + public CursorBasePaginatedResponse findComments(Long userId, Long postId, Long cursor, int size) { + Slice commentSlice = commentRepository.findByPostId(postId, cursor, PageRequest.ofSize(size)); + return CursorBasePaginatedResponse.of( + commentSlice.map(comment -> createCommentResponse(comment, userId)) + ); } - private CommentResponse createCommentResponse(Comment comment) { - User user = userRepository.findById(comment.getUserNo()) + private CommentResponse createCommentResponse(Comment comment, Long userId) { + User author = userRepository.findById(comment.getUserNo()) .orElseThrow(() -> new BadRequestException(ErrorCode.USER_NOT_FOUND)); - return CommentResponse.of(comment, user); + return CommentResponse.of(comment, author, author.getId().equals(userId)); } } diff --git a/src/main/java/com/swyp8team2/comment/presentation/CommentController.java b/src/main/java/com/swyp8team2/comment/presentation/CommentController.java index 9f21cba5..69002fca 100644 --- a/src/main/java/com/swyp8team2/comment/presentation/CommentController.java +++ b/src/main/java/com/swyp8team2/comment/presentation/CommentController.java @@ -47,8 +47,7 @@ public ResponseEntity> selectCommen @RequestParam(value = "size", required = false, defaultValue = "10") @Min(1) int size, @AuthenticationPrincipal UserInfo userInfo ) { - CursorBasePaginatedResponse response = commentService.findComments(postId, cursor, size); - return ResponseEntity.ok(response); + return ResponseEntity.ok(commentService.findComments(userInfo.userId(), postId, cursor, size)); } @DeleteMapping("/{commentId}") diff --git a/src/main/java/com/swyp8team2/comment/presentation/dto/CommentResponse.java b/src/main/java/com/swyp8team2/comment/presentation/dto/CommentResponse.java index ea3c6f67..3820ec88 100644 --- a/src/main/java/com/swyp8team2/comment/presentation/dto/CommentResponse.java +++ b/src/main/java/com/swyp8team2/comment/presentation/dto/CommentResponse.java @@ -12,7 +12,8 @@ public record CommentResponse( String content, AuthorDto author, Long voteImageId, - LocalDateTime createdAt + LocalDateTime createdAt, + boolean isAuthor ) implements CursorDto { @Override @@ -21,12 +22,13 @@ public long getId() { return commentId; } - public static CommentResponse of(Comment comment, User user) { + public static CommentResponse of(Comment comment, User user, boolean isAuthor) { return new CommentResponse(comment.getId(), - comment.getContent(), - new AuthorDto(user.getId(), user.getNickname(), user.getProfileUrl()), - null, - comment.getCreatedAt() - ); + comment.getContent(), + new AuthorDto(user.getId(), user.getNickname(), user.getProfileUrl()), + null, + comment.getCreatedAt(), + isAuthor + ); } } From 955d4267b2b3a23370b60bc30f8e3aac7dd0de74 Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Thu, 27 Feb 2025 23:07:08 +0900 Subject: [PATCH 4/9] =?UTF-8?q?test:=20=EB=8C=93=EA=B8=80=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comment/application/CommentServiceTest.java | 4 ++-- .../comment/presentation/CommentControllerTest.java | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/swyp8team2/comment/application/CommentServiceTest.java b/src/test/java/com/swyp8team2/comment/application/CommentServiceTest.java index 09d5e374..deb6f272 100644 --- a/src/test/java/com/swyp8team2/comment/application/CommentServiceTest.java +++ b/src/test/java/com/swyp8team2/comment/application/CommentServiceTest.java @@ -78,7 +78,7 @@ void findComments() { given(userRepository.findById(100L)).willReturn(Optional.of(user)); // when - CursorBasePaginatedResponse response = commentService.findComments(postId, cursor, size); + CursorBasePaginatedResponse response = commentService.findComments(user.getId(), postId, cursor, size); // then assertThat(response.data()).hasSize(2); @@ -113,7 +113,7 @@ void findComments_userNotFound() { given(userRepository.findById(100L)).willReturn(Optional.empty()); // when & then - assertThatThrownBy(() -> commentService.findComments(postId, cursor, size)) + assertThatThrownBy(() -> commentService.findComments(1L, postId, cursor, size)) .isInstanceOf(BadRequestException.class) .hasMessage((ErrorCode.USER_NOT_FOUND.getMessage())); } diff --git a/src/test/java/com/swyp8team2/comment/presentation/CommentControllerTest.java b/src/test/java/com/swyp8team2/comment/presentation/CommentControllerTest.java index ab316900..e568814e 100644 --- a/src/test/java/com/swyp8team2/comment/presentation/CommentControllerTest.java +++ b/src/test/java/com/swyp8team2/comment/presentation/CommentControllerTest.java @@ -72,14 +72,15 @@ void findComments() throws Exception { "댓글 내용", new AuthorDto(100L, "닉네임", "http://example.com/profile.png"), null, - LocalDateTime.now() + LocalDateTime.now(), + false ); List commentList = Collections.singletonList(commentResponse); CursorBasePaginatedResponse response = new CursorBasePaginatedResponse<>(null, false, commentList); - when(commentService.findComments(eq(postId), eq(cursor), eq(size))).thenReturn(response); + when(commentService.findComments(null, eq(postId), eq(cursor), eq(size))).thenReturn(response); //when mockMvc.perform(get("/posts/{postId}/comments", "1")) @@ -125,11 +126,14 @@ void findComments() throws Exception { .description("작성자가 투표한 이미지 Id (투표 없을 시 null)"), fieldWithPath("data[].createdAt") .type(JsonFieldType.STRING) - .description("댓글 작성일") + .description("댓글 작성일"), + fieldWithPath("data[].isAuthor") + .type(JsonFieldType.BOOLEAN) + .description("작성자 여부") ) )); - verify(commentService, times(1)).findComments(eq(postId), eq(cursor), eq(size)); + verify(commentService, times(1)).findComments(null, eq(postId), eq(cursor), eq(size)); } @Test From 7f7e69490aba62aa9b43f6fb08caa58ced0d108c Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Thu, 27 Feb 2025 23:10:45 +0900 Subject: [PATCH 5/9] =?UTF-8?q?feat:=20=EB=8D=94=EB=AF=B8=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=9E=88=EC=9D=84=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=B6=94=EA=B0=80=20x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/swyp8team2/common/dev/DataInitializer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/swyp8team2/common/dev/DataInitializer.java b/src/main/java/com/swyp8team2/common/dev/DataInitializer.java index 9665d462..644eff7a 100644 --- a/src/main/java/com/swyp8team2/common/dev/DataInitializer.java +++ b/src/main/java/com/swyp8team2/common/dev/DataInitializer.java @@ -39,6 +39,9 @@ public class DataInitializer { @Transactional public void init() { + if (userRepository.count() > 0) { + return; + } List adjectives = nicknameAdjectiveRepository.findAll(); User testUser = userRepository.save(User.create("nickname", "https://t1.kakaocdn.net/account_images/default_profile.jpeg")); TokenPair tokenPair = jwtService.createToken(testUser.getId()); From defd9d4f0b0cc2fd6976b75bc6150e5f59d9d6eb Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Thu, 27 Feb 2025 23:44:34 +0900 Subject: [PATCH 6/9] =?UTF-8?q?feat:=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20?= =?UTF-8?q?=ED=88=AC=ED=91=9C=20=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../swyp8team2/comment/application/CommentService.java | 8 +++++++- .../comment/presentation/CommentController.java | 4 +++- .../comment/presentation/dto/CommentResponse.java | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/swyp8team2/comment/application/CommentService.java b/src/main/java/com/swyp8team2/comment/application/CommentService.java index 49d72c30..bfe61db3 100644 --- a/src/main/java/com/swyp8team2/comment/application/CommentService.java +++ b/src/main/java/com/swyp8team2/comment/application/CommentService.java @@ -10,6 +10,8 @@ import com.swyp8team2.common.exception.ErrorCode; import com.swyp8team2.user.domain.User; import com.swyp8team2.user.domain.UserRepository; +import com.swyp8team2.vote.domain.Vote; +import com.swyp8team2.vote.domain.VoteRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.PageRequest; @@ -25,6 +27,7 @@ public class CommentService { private final UserRepository userRepository; private final CommentRepository commentRepository; + private final VoteRepository voteRepository; @Transactional public void createComment(Long postId, CreateCommentRequest request, UserInfo userInfo) { @@ -42,6 +45,9 @@ public CursorBasePaginatedResponse findComments(Long userId, Lo private CommentResponse createCommentResponse(Comment comment, Long userId) { User author = userRepository.findById(comment.getUserNo()) .orElseThrow(() -> new BadRequestException(ErrorCode.USER_NOT_FOUND)); - return CommentResponse.of(comment, author, author.getId().equals(userId)); + Long voteImageId = voteRepository.findByUserIdAndPostId(userId, comment.getPostId()) + .map(Vote::getPostImageId) + .orElse(null); + return CommentResponse.of(comment, author, author.getId().equals(userId), voteImageId); } } diff --git a/src/main/java/com/swyp8team2/comment/presentation/CommentController.java b/src/main/java/com/swyp8team2/comment/presentation/CommentController.java index 69002fca..b727fb2b 100644 --- a/src/main/java/com/swyp8team2/comment/presentation/CommentController.java +++ b/src/main/java/com/swyp8team2/comment/presentation/CommentController.java @@ -22,6 +22,7 @@ import java.time.LocalDateTime; import java.util.List; +import java.util.Optional; @RestController @RequiredArgsConstructor @@ -47,7 +48,8 @@ public ResponseEntity> selectCommen @RequestParam(value = "size", required = false, defaultValue = "10") @Min(1) int size, @AuthenticationPrincipal UserInfo userInfo ) { - return ResponseEntity.ok(commentService.findComments(userInfo.userId(), postId, cursor, size)); + Long userId = Optional.ofNullable(userInfo).map(UserInfo::userId).orElse(null); + return ResponseEntity.ok(commentService.findComments(userId, postId, cursor, size)); } @DeleteMapping("/{commentId}") diff --git a/src/main/java/com/swyp8team2/comment/presentation/dto/CommentResponse.java b/src/main/java/com/swyp8team2/comment/presentation/dto/CommentResponse.java index 3820ec88..89848202 100644 --- a/src/main/java/com/swyp8team2/comment/presentation/dto/CommentResponse.java +++ b/src/main/java/com/swyp8team2/comment/presentation/dto/CommentResponse.java @@ -22,11 +22,11 @@ public long getId() { return commentId; } - public static CommentResponse of(Comment comment, User user, boolean isAuthor) { + public static CommentResponse of(Comment comment, User user, boolean isAuthor, Long voteImageId) { return new CommentResponse(comment.getId(), comment.getContent(), new AuthorDto(user.getId(), user.getNickname(), user.getProfileUrl()), - null, + voteImageId, comment.getCreatedAt(), isAuthor ); From 14846a4f0efa8834f01b1a7d2c071905014f4e33 Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Thu, 27 Feb 2025 23:44:49 +0900 Subject: [PATCH 7/9] =?UTF-8?q?test:=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20?= =?UTF-8?q?=EB=8C=93=EA=B8=80=20=EC=97=AC=EB=B6=80=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../swyp8team2/comment/application/CommentServiceTest.java | 5 +++++ .../comment/presentation/CommentControllerTest.java | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/swyp8team2/comment/application/CommentServiceTest.java b/src/test/java/com/swyp8team2/comment/application/CommentServiceTest.java index deb6f272..bd5b9844 100644 --- a/src/test/java/com/swyp8team2/comment/application/CommentServiceTest.java +++ b/src/test/java/com/swyp8team2/comment/application/CommentServiceTest.java @@ -11,6 +11,7 @@ import com.swyp8team2.user.domain.Role; import com.swyp8team2.user.domain.User; import com.swyp8team2.user.domain.UserRepository; +import com.swyp8team2.vote.domain.VoteRepository; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -43,6 +44,9 @@ class CommentServiceTest { @InjectMocks private CommentService commentService; + @Mock + private VoteRepository voteRepository; + @Test @DisplayName("댓글 생성") void createComment() { @@ -74,6 +78,7 @@ void findComments() { // Mock 설정 given(commentRepository.findByPostId(eq(postId), eq(cursor), any(PageRequest.class))).willReturn(commentSlice); + given(voteRepository.findByUserIdAndPostId(eq(user.getId()), eq(postId))).willReturn(Optional.empty()); // 각 댓글마다 user_no=100L 이므로, findById(100L)만 호출됨 given(userRepository.findById(100L)).willReturn(Optional.of(user)); diff --git a/src/test/java/com/swyp8team2/comment/presentation/CommentControllerTest.java b/src/test/java/com/swyp8team2/comment/presentation/CommentControllerTest.java index e568814e..da30223a 100644 --- a/src/test/java/com/swyp8team2/comment/presentation/CommentControllerTest.java +++ b/src/test/java/com/swyp8team2/comment/presentation/CommentControllerTest.java @@ -80,7 +80,7 @@ void findComments() throws Exception { CursorBasePaginatedResponse response = new CursorBasePaginatedResponse<>(null, false, commentList); - when(commentService.findComments(null, eq(postId), eq(cursor), eq(size))).thenReturn(response); + when(commentService.findComments(eq(null), eq(postId), eq(cursor), eq(size))).thenReturn(response); //when mockMvc.perform(get("/posts/{postId}/comments", "1")) @@ -133,7 +133,7 @@ void findComments() throws Exception { ) )); - verify(commentService, times(1)).findComments(null, eq(postId), eq(cursor), eq(size)); + verify(commentService, times(1)).findComments(eq(null), eq(postId), eq(cursor), eq(size)); } @Test From af7cbf2e2ebccc532d72467d2f5dd69851bcffec Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Thu, 27 Feb 2025 23:45:10 +0900 Subject: [PATCH 8/9] =?UTF-8?q?feat:=20social=20account=20unique=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/swyp8team2/auth/domain/SocialAccount.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/swyp8team2/auth/domain/SocialAccount.java b/src/main/java/com/swyp8team2/auth/domain/SocialAccount.java index 23f784e7..3675e6c4 100644 --- a/src/main/java/com/swyp8team2/auth/domain/SocialAccount.java +++ b/src/main/java/com/swyp8team2/auth/domain/SocialAccount.java @@ -2,6 +2,7 @@ import com.swyp8team2.auth.application.oauth.dto.OAuthUserInfo; import com.swyp8team2.common.domain.BaseEntity; +import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; @@ -25,6 +26,7 @@ public class SocialAccount extends BaseEntity { private Long userId; + @Column(nullable = false, unique = true) private String socialId; @Enumerated(EnumType.STRING) From d21b201eb5ac0219ca4f6d6ca7afd86f4dec912a Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Thu, 27 Feb 2025 23:47:17 +0900 Subject: [PATCH 9/9] =?UTF-8?q?refactor:=20=EC=86=8C=EC=85=9C=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=8B=A4=ED=8C=A8=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/swyp8team2/auth/application/oauth/OAuthService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/swyp8team2/auth/application/oauth/OAuthService.java b/src/main/java/com/swyp8team2/auth/application/oauth/OAuthService.java index 826e77bc..dd6516a4 100644 --- a/src/main/java/com/swyp8team2/auth/application/oauth/OAuthService.java +++ b/src/main/java/com/swyp8team2/auth/application/oauth/OAuthService.java @@ -3,6 +3,7 @@ import com.swyp8team2.auth.application.oauth.dto.KakaoAuthResponse; import com.swyp8team2.auth.application.oauth.dto.OAuthUserInfo; import com.swyp8team2.common.config.KakaoOAuthConfig; +import com.swyp8team2.common.exception.BadRequestException; import com.swyp8team2.common.exception.ErrorCode; import com.swyp8team2.common.exception.InternalServerException; import lombok.RequiredArgsConstructor; @@ -29,8 +30,8 @@ public OAuthUserInfo getUserInfo(String code, String redirectUri) { .fetchUserInfo(BEARER + kakaoAuthResponse.accessToken()) .toOAuthUserInfo(); } catch (Exception e) { - log.error("소셜 로그인 실패", e); - throw new InternalServerException(ErrorCode.SOCIAL_AUTHENTICATION_FAILED); + log.debug("소셜 로그인 실패 {}", e.getMessage()); + throw new BadRequestException(ErrorCode.SOCIAL_AUTHENTICATION_FAILED); } }