From 742f2398de4e4c206554b20df403f62276751c00 Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Mon, 30 Sep 2024 05:03:41 +0900 Subject: [PATCH 1/3] =?UTF-8?q?#38=20[feat]=20:=20=EC=B9=B4=EC=B9=B4?= =?UTF-8?q?=EC=98=A4=20=EC=86=8C=EC=85=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=8B=9C=20=EC=9D=B4=EB=A9=94=EC=9D=BC=EC=9D=84=20=EA=B0=80?= =?UTF-8?q?=EC=A0=B8=EC=98=A8=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9a5d0bc..d3d5780 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -42,6 +42,7 @@ spring: client-secret: ${OAUTH_KAKAO_CLIENT_SECRET} scope: - profile_nickname + - account_email authorization-grant-type: authorization_code redirect-uri: ${OAUTH_KAKAO_REDIRECT_URI} client-name: Kakao From 8f7c11fa7b96032783eacb2d19d81b9c060899b1 Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Mon, 30 Sep 2024 05:04:25 +0900 Subject: [PATCH 2/3] =?UTF-8?q?#38=20[feat]=20:=20=EC=86=8C=EC=85=9C=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=8B=9C=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EC=9D=B4=EB=A9=94=EC=9D=BC=EC=9D=84=20=EA=B0=80=EC=A0=B8?= =?UTF-8?q?=EC=98=AC=20=EC=88=98=20=EC=9E=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/side/onetime/auth/dto/GoogleUserInfo.java | 5 +++++ src/main/java/side/onetime/auth/dto/KakaoUserInfo.java | 7 +++++-- src/main/java/side/onetime/auth/dto/NaverUserInfo.java | 5 +++++ src/main/java/side/onetime/auth/dto/OAuth2UserInfo.java | 1 + .../onetime/auth/handler/OAuthLoginSuccessHandler.java | 4 +++- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/side/onetime/auth/dto/GoogleUserInfo.java b/src/main/java/side/onetime/auth/dto/GoogleUserInfo.java index 4037b06..94bb596 100644 --- a/src/main/java/side/onetime/auth/dto/GoogleUserInfo.java +++ b/src/main/java/side/onetime/auth/dto/GoogleUserInfo.java @@ -24,4 +24,9 @@ public String getProvider() { public String getName() { return (String) attributes.get("name"); } + + @Override + public String getEmail() { + return (String) attributes.get("email"); + } } \ No newline at end of file diff --git a/src/main/java/side/onetime/auth/dto/KakaoUserInfo.java b/src/main/java/side/onetime/auth/dto/KakaoUserInfo.java index d288e32..d5c6b8c 100644 --- a/src/main/java/side/onetime/auth/dto/KakaoUserInfo.java +++ b/src/main/java/side/onetime/auth/dto/KakaoUserInfo.java @@ -12,7 +12,6 @@ public class KakaoUserInfo implements OAuth2UserInfo { @Override public String getProviderId() { - // Long 타입이기 때문에 toString으로 변환 return attributes.get("id").toString(); } @@ -23,7 +22,11 @@ public String getProvider() { @Override public String getName() { - // kakao_account라는 Map에서 추출 return (String) ((Map) attributes.get("properties")).get("nickname"); } + + @Override + public String getEmail() { + return (String) ((Map) attributes.get("kakao_account")).get("email"); + } } \ No newline at end of file diff --git a/src/main/java/side/onetime/auth/dto/NaverUserInfo.java b/src/main/java/side/onetime/auth/dto/NaverUserInfo.java index 3ac4398..98bb5c0 100644 --- a/src/main/java/side/onetime/auth/dto/NaverUserInfo.java +++ b/src/main/java/side/onetime/auth/dto/NaverUserInfo.java @@ -24,4 +24,9 @@ public String getProvider() { public String getName() { return (String) attributes.get("name"); } + + @Override + public String getEmail() { + return (String) attributes.get("email"); + } } \ No newline at end of file diff --git a/src/main/java/side/onetime/auth/dto/OAuth2UserInfo.java b/src/main/java/side/onetime/auth/dto/OAuth2UserInfo.java index f6e850c..8e093e5 100644 --- a/src/main/java/side/onetime/auth/dto/OAuth2UserInfo.java +++ b/src/main/java/side/onetime/auth/dto/OAuth2UserInfo.java @@ -4,4 +4,5 @@ public interface OAuth2UserInfo { String getProviderId(); String getProvider(); String getName(); + String getEmail(); } \ No newline at end of file diff --git a/src/main/java/side/onetime/auth/handler/OAuthLoginSuccessHandler.java b/src/main/java/side/onetime/auth/handler/OAuthLoginSuccessHandler.java index 698d57b..2602c80 100644 --- a/src/main/java/side/onetime/auth/handler/OAuthLoginSuccessHandler.java +++ b/src/main/java/side/onetime/auth/handler/OAuthLoginSuccessHandler.java @@ -75,6 +75,7 @@ private OAuth2UserInfo extractOAuth2UserInfo(OAuth2AuthenticationToken token, St private void handleAuthentication(HttpServletRequest request, HttpServletResponse response, OAuth2UserInfo oAuth2UserInfo, String provider) throws IOException { String providerId = oAuth2UserInfo.getProviderId(); String name = oAuth2UserInfo.getName(); + String email = oAuth2UserInfo.getEmail(); User existUser = userRepository.findByProviderId(providerId); @@ -86,9 +87,10 @@ private void handleAuthentication(HttpServletRequest request, HttpServletRespons handleExistingUser(request, response, existUser); } - log.info("유저 이름 : {}", name); + log.info("NAME : {}", name); log.info("PROVIDER : {}", provider); log.info("PROVIDER_ID : {}", providerId); + log.info("EMAIL : {}", email); } // 신규 유저 처리 From 02a26501923a60a284185ca30e7b0772417503ae Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Mon, 30 Sep 2024 05:04:48 +0900 Subject: [PATCH 3/3] =?UTF-8?q?#38=20[style]=20:=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=EC=9D=84=20=EB=B3=80=EA=B2=BD=ED=95=9C?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/{application.yml => application.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/{application.yml => application.yaml} (100%) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yaml similarity index 100% rename from src/main/resources/application.yml rename to src/main/resources/application.yaml