From 1ee7747ff6430c733daa3725ec287a78f67e777d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B5=90=ED=9C=98?= Date: Tue, 3 Sep 2024 13:11:01 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=9C=A0=EC=A0=80=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9D=B4=20=EC=95=88=EB=90=98=EB=8A=94=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0(#138)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../soongsil/CoffeeChat/config/jwt/JWTFilter.java | 2 +- .../CoffeeChat/dto/Oauth/CustomOAuth2User.java | 1 - .../com/soongsil/CoffeeChat/dto/Oauth/UserDTO.java | 2 +- .../CoffeeChat/service/CustomOAuth2UserService.java | 12 ++---------- .../soongsil/CoffeeChat/util/email/EmailUtil.java | 1 + src/main/resources/application.yml | 2 +- 6 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/soongsil/CoffeeChat/config/jwt/JWTFilter.java b/src/main/java/com/soongsil/CoffeeChat/config/jwt/JWTFilter.java index d44b981..288bffa 100644 --- a/src/main/java/com/soongsil/CoffeeChat/config/jwt/JWTFilter.java +++ b/src/main/java/com/soongsil/CoffeeChat/config/jwt/JWTFilter.java @@ -2,6 +2,7 @@ import java.io.IOException; +import com.soongsil.CoffeeChat.dto.Oauth.UserDTO; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -10,7 +11,6 @@ import org.springframework.web.filter.OncePerRequestFilter; import com.soongsil.CoffeeChat.dto.Oauth.CustomOAuth2User; -import com.soongsil.CoffeeChat.dto.UserDTO; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; diff --git a/src/main/java/com/soongsil/CoffeeChat/dto/Oauth/CustomOAuth2User.java b/src/main/java/com/soongsil/CoffeeChat/dto/Oauth/CustomOAuth2User.java index 9e7c6c9..ff04c29 100644 --- a/src/main/java/com/soongsil/CoffeeChat/dto/Oauth/CustomOAuth2User.java +++ b/src/main/java/com/soongsil/CoffeeChat/dto/Oauth/CustomOAuth2User.java @@ -7,7 +7,6 @@ import org.springframework.security.core.GrantedAuthority; import org.springframework.security.oauth2.core.user.OAuth2User; -import com.soongsil.CoffeeChat.dto.UserDTO; public class CustomOAuth2User implements OAuth2User { private final UserDTO userDTO; diff --git a/src/main/java/com/soongsil/CoffeeChat/dto/Oauth/UserDTO.java b/src/main/java/com/soongsil/CoffeeChat/dto/Oauth/UserDTO.java index 9e594e4..9ac6a4c 100644 --- a/src/main/java/com/soongsil/CoffeeChat/dto/Oauth/UserDTO.java +++ b/src/main/java/com/soongsil/CoffeeChat/dto/Oauth/UserDTO.java @@ -1,4 +1,4 @@ -package com.soongsil.CoffeeChat.dto; +package com.soongsil.CoffeeChat.dto.Oauth; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/soongsil/CoffeeChat/service/CustomOAuth2UserService.java b/src/main/java/com/soongsil/CoffeeChat/service/CustomOAuth2UserService.java index f76fd1a..ff71120 100644 --- a/src/main/java/com/soongsil/CoffeeChat/service/CustomOAuth2UserService.java +++ b/src/main/java/com/soongsil/CoffeeChat/service/CustomOAuth2UserService.java @@ -1,18 +1,13 @@ package com.soongsil.CoffeeChat.service; import com.soongsil.CoffeeChat.controller.exception.CustomException; +import com.soongsil.CoffeeChat.dto.Oauth.*; import org.springframework.security.oauth2.client.userinfo.DefaultOAuth2UserService; import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest; import org.springframework.security.oauth2.core.OAuth2AuthenticationException; import org.springframework.security.oauth2.core.user.OAuth2User; import org.springframework.stereotype.Service; -import com.soongsil.CoffeeChat.dto.Oauth.CustomOAuth2User; -import com.soongsil.CoffeeChat.dto.Oauth.GoogleResponse; -import com.soongsil.CoffeeChat.dto.Oauth.KakaoResponse; -import com.soongsil.CoffeeChat.dto.Oauth.NaverResponse; -import com.soongsil.CoffeeChat.dto.Oauth.OAuth2Response; -import com.soongsil.CoffeeChat.dto.UserDTO; import com.soongsil.CoffeeChat.entity.User; import com.soongsil.CoffeeChat.repository.User.UserRepository; @@ -30,10 +25,7 @@ public CustomOAuth2UserService(UserRepository userRepository) { private User findUserByUsername(String username){ return userRepository.findByUsername(username) - .orElseThrow(() -> new CustomException( - USER_NOT_FOUND.getHttpStatusCode(), - USER_NOT_FOUND.getErrorMessage()) - ); + .orElse(null); } //리소스 서버에서 제공되는 유저정보 가져오기 diff --git a/src/main/java/com/soongsil/CoffeeChat/util/email/EmailUtil.java b/src/main/java/com/soongsil/CoffeeChat/util/email/EmailUtil.java index 671fc2d..bbe38ac 100644 --- a/src/main/java/com/soongsil/CoffeeChat/util/email/EmailUtil.java +++ b/src/main/java/com/soongsil/CoffeeChat/util/email/EmailUtil.java @@ -47,6 +47,7 @@ public String sendAuthenticationEmail(String receiver) throws InterruptedExcepti } catch (Exception e) { // 예외가 발생했을 때 로그를 남기고, 기본 코드 반환 등을 처리 System.out.println("SQS 메시지 전송 실패: " + e.getMessage()); + throw new RuntimeException("메일전송실패"); } return code; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 28bfaca..3eb7516 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -13,7 +13,7 @@ spring: password: ${DB_PW} jpa: hibernate: - ddl-auto: none + ddl-auto: update naming: physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl database: mysql