From cf6a47ed145292a0283622fe7d7f9ab9a2eb3206 Mon Sep 17 00:00:00 2001 From: gkfktkrh153 Date: Thu, 21 Mar 2024 01:21:06 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EC=B1=84=ED=8C=85=20=EC=97=B0=EA=B2=B0=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=ED=83=80=EC=9E=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../farmingsoon/domain/chat/dto/ChattingConnectResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/api/farmingsoon/domain/chat/dto/ChattingConnectResponse.java b/src/main/java/com/api/farmingsoon/domain/chat/dto/ChattingConnectResponse.java index ca4bcf7..e8f4952 100644 --- a/src/main/java/com/api/farmingsoon/domain/chat/dto/ChattingConnectResponse.java +++ b/src/main/java/com/api/farmingsoon/domain/chat/dto/ChattingConnectResponse.java @@ -8,7 +8,7 @@ public class ChattingConnectResponse { private Long connectMemberId; - private final String type = "SEND"; + private final String type = "CONNECT"; public ChattingConnectResponse(Long connectMemberId) { this.connectMemberId = connectMemberId; From f49cb9fef3de19b6985a0eaf308d29b4f9adcec2 Mon Sep 17 00:00:00 2001 From: gkfktkrh153 Date: Thu, 21 Mar 2024 18:47:02 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EC=86=8C=EC=85=9C=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EC=8B=9C=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EB=B0=A9=EC=8B=9D=20=EB=B3=80=EA=B2=BD=20+=20Respo?= =?UTF-8?q?nse=20API=20=EC=8A=A4=ED=8E=99=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/oauth/OAuthSuccessHandler.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/api/farmingsoon/common/security/oauth/OAuthSuccessHandler.java b/src/main/java/com/api/farmingsoon/common/security/oauth/OAuthSuccessHandler.java index 29dba39..ecab91c 100644 --- a/src/main/java/com/api/farmingsoon/common/security/oauth/OAuthSuccessHandler.java +++ b/src/main/java/com/api/farmingsoon/common/security/oauth/OAuthSuccessHandler.java @@ -6,6 +6,7 @@ import com.api.farmingsoon.common.security.jwt.JwtToken; import com.api.farmingsoon.common.util.CookieUtils; import com.api.farmingsoon.common.util.JwtUtils; +import com.api.farmingsoon.domain.member.dto.LoginResponse; import com.api.farmingsoon.domain.member.model.Member; import com.api.farmingsoon.domain.member.model.MemberRole; import com.api.farmingsoon.domain.member.repository.MemberRepository; @@ -37,16 +38,17 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo OAuth2User oAuth2User = (OAuth2User) authentication.getPrincipal(); String email = oAuth2User.getAttribute("email"); - Optional findMember = memberRepository.findByEmail(email); - String name = oAuth2User.getAttribute("name"); String picture = oAuth2User.getAttribute("picture"); + String provider = oAuth2User.getAttribute("provider"); + + Optional findMember = memberRepository.findByEmail(email + "_" + provider); // 회원이 아닌 경우에 회원 가입 진행 Member member = null; if (findMember.isEmpty()) { member = Member.builder() - .email(email) + .email(email + "_" + provider) .nickname(name) .role(MemberRole.MEMBER) .profileImg(picture) @@ -54,10 +56,7 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo memberRepository.save(member); } else { - member = findMember.orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MEMBER)); - member.updateSocialMember(email, name, picture); - - memberRepository.save(member); + member = findMember.get(); } // OAuth2User 객체에서 권한 가져옴 @@ -70,7 +69,7 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo response.setStatus(200); response.getWriter().write( - objectMapper.writeValueAsString(jwtToken) + objectMapper.writeValueAsString(LoginResponse.of(member)) ); } }