diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml
index 5213cb3..e1c3968 100644
--- a/.github/workflows/actions.yml
+++ b/.github/workflows/actions.yml
@@ -2,7 +2,7 @@ name: ModernFarmer CI/CD
on:
push:
- branches: ["feature_11/에러처리-추가"]
+ branches: ["feature_13/카카오,-구글-로그인-수정"]
pull_request:
branches: ["dev"]
diff --git a/.jpb/jpb-settings.xml b/.jpb/jpb-settings.xml
new file mode 100644
index 0000000..484f362
--- /dev/null
+++ b/.jpb/jpb-settings.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/modernfarmer/server/farmususer/user/controller/AuthController.java b/src/main/java/modernfarmer/server/farmususer/user/controller/AuthController.java
index bcbae14..72beb69 100644
--- a/src/main/java/modernfarmer/server/farmususer/user/controller/AuthController.java
+++ b/src/main/java/modernfarmer/server/farmususer/user/controller/AuthController.java
@@ -36,33 +36,6 @@ public TokenResponseDto kakaoLogin(HttpServletRequest request) {
return reissueTokenResponseDto;
}
-//
-// @DeleteMapping("/logout")
-// public ResponseDto logout(HttpServletRequest request) {
-//
-//
-// String userId = jwtTokenProvider.getUserId(request);
-//
-// ResponseDto logoutResponseDto = authService.logout(Long.valueOf(userId));
-//
-// LOGGER.info("로그아웃 완료");
-//
-// return logoutResponseDto;
-// }
-//
-// @GetMapping(value = "/reissue-token")
-// public TokenResponseDto reissueToken(HttpServletRequest request) {
-//
-// String userId = jwtTokenProvider.getUserId(request);
-// String refreshToken = jwtTokenProvider.resolveToken(request);
-//
-// TokenResponseDto reissueTokenResponseDto = authService.reissueToken(refreshToken, Long.valueOf(userId));
-//
-// LOGGER.info("토큰 재발급 완료");
-//
-// return reissueTokenResponseDto;
-// }
-
@PostMapping(value = "/google-login")
public TokenResponseDto googleLogin(HttpServletRequest request) {
diff --git a/src/main/java/modernfarmer/server/farmususer/user/dto/response/GoogleUserResponseDto.java b/src/main/java/modernfarmer/server/farmususer/user/dto/response/GoogleUserResponseDto.java
index 410a17f..6ede66f 100644
--- a/src/main/java/modernfarmer/server/farmususer/user/dto/response/GoogleUserResponseDto.java
+++ b/src/main/java/modernfarmer/server/farmususer/user/dto/response/GoogleUserResponseDto.java
@@ -11,10 +11,6 @@ public class GoogleUserResponseDto {
private String id;
private String email;
- private boolean verified_email;
- private String name;
- private String given_name;
- private String family_name;
private String picture;
- private String locale;
+ private String name;
}
diff --git a/src/main/java/modernfarmer/server/farmususer/user/dto/response/KakaoUserResponseDto.java b/src/main/java/modernfarmer/server/farmususer/user/dto/response/KakaoUserResponseDto.java
index b2d1756..cd44f2f 100644
--- a/src/main/java/modernfarmer/server/farmususer/user/dto/response/KakaoUserResponseDto.java
+++ b/src/main/java/modernfarmer/server/farmususer/user/dto/response/KakaoUserResponseDto.java
@@ -2,6 +2,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@@ -9,6 +10,7 @@
@Getter
@Builder
+@AllArgsConstructor
public class KakaoUserResponseDto {
private long id;
@@ -16,33 +18,33 @@ public class KakaoUserResponseDto {
public KakaoUserResponseDto(@JsonProperty("id") long id) {
this.id = id;
}
-// private UserProfileDTO kakao_account;
-//
-//
-// @Setter
-// @Getter
-// public class UserProfileDTO {
-// private boolean profileNicknameNeedsAgreement;
-// private boolean profileImageNeedsAgreement;
-// private ProfileData profile;
-// private boolean hasEmail;
-// private boolean emailNeedsAgreement;
-// private boolean isEmailValid;
-// private boolean isEmailVerified;
-// private String email;
-//
-//
-//
-//
-// @Getter
-// @Setter
-// public class ProfileData {
-// private String nickname;
-// private String thumbnailImageUrl;
-// private String profileImageUrl;
-// private boolean isDefaultImage;
-// }
-// }
+ private UserProfileDTO kakao_account;
+
+
+ @Setter
+ @Getter
+ public class UserProfileDTO {
+ private boolean profileNicknameNeedsAgreement;
+ private boolean profileImageNeedsAgreement;
+ private ProfileData profile;
+ private boolean hasEmail;
+ private boolean emailNeedsAgreement;
+ private boolean isEmailValid;
+ private boolean isEmailVerified;
+ private String email;
+
+
+
+
+ @Getter
+ @Setter
+ public class ProfileData {
+ private String nickname;
+ private String thumbnail_image_Url;
+ private String profile_image_url;
+ private boolean isDefaultImage;
+ }
+ }
diff --git a/src/main/java/modernfarmer/server/farmususer/user/dto/response/TokenResponseDto.java b/src/main/java/modernfarmer/server/farmususer/user/dto/response/TokenResponseDto.java
index e746e38..d992472 100644
--- a/src/main/java/modernfarmer/server/farmususer/user/dto/response/TokenResponseDto.java
+++ b/src/main/java/modernfarmer/server/farmususer/user/dto/response/TokenResponseDto.java
@@ -17,4 +17,6 @@ public class TokenResponseDto {
private String accessToken;
private String refreshToken;
+
+ private boolean early;
}
\ No newline at end of file
diff --git a/src/main/java/modernfarmer/server/farmususer/user/entity/User.java b/src/main/java/modernfarmer/server/farmususer/user/entity/User.java
index 7bf3e13..5893b64 100644
--- a/src/main/java/modernfarmer/server/farmususer/user/entity/User.java
+++ b/src/main/java/modernfarmer/server/farmususer/user/entity/User.java
@@ -35,4 +35,12 @@ public class User {
private String role;
+ @Size(max = 45)
+ @Column(name = "nickname", length = 45)
+ private String nickname;
+
+ @Size(max = 255)
+ @Column(name = "profile_image")
+ private String profileImage;
+
}
\ No newline at end of file
diff --git a/src/main/java/modernfarmer/server/farmususer/user/service/AuthService.java b/src/main/java/modernfarmer/server/farmususer/user/service/AuthService.java
index 20add15..1b73a5c 100644
--- a/src/main/java/modernfarmer/server/farmususer/user/service/AuthService.java
+++ b/src/main/java/modernfarmer/server/farmususer/user/service/AuthService.java
@@ -1,5 +1,6 @@
package modernfarmer.server.farmususer.user.service;
+
import lombok.extern.slf4j.Slf4j;
import modernfarmer.server.farmususer.user.dto.response.GoogleUserResponseDto;
import modernfarmer.server.farmususer.user.dto.response.KakaoUserResponseDto;
@@ -9,7 +10,6 @@
import modernfarmer.server.farmususer.user.util.JwtTokenProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
@@ -28,6 +28,7 @@ public class AuthService{
public UserRepository userRepository;
private final WebClient webClient;
+ private boolean early = false;
@Autowired
public AuthService(WebClient webClient, UserRepository userRepository, JwtTokenProvider jwtTokenProvider, RedisTemplate redisTemplate) {
@@ -44,24 +45,20 @@ public TokenResponseDto googleLogin(String accessToken) {
Mono userInfoMono = getUserGoogleInfo(accessToken);
GoogleUserResponseDto userInfo = userInfoMono.block();
-// LOGGER.info(String.valueOf(userInfo.getAccount_email()));
-// LOGGER.info(String.valueOf(userInfo.getProfile_nickname()));
-// LOGGER.info(String.valueOf(userInfo.getProfile_image()));
-
-// LOGGER.info(String.valueOf(userInfo.getKakao_account().getEmail()));
-// LOGGER.info(String.valueOf(userInfo.getKakao_account().getProfile().getProfileImageUrl()));
-// LOGGER.info(String.valueOf(userInfo.getKakao_account().getProfile().getNickname()));
Optional userData = userRepository.findByUsernumber(String.valueOf(userInfo.getId()));
+ log.info(String.valueOf(userInfo.getEmail()));
+ log.info(String.valueOf(userInfo.getPicture()));
+ log.info(String.valueOf(userInfo.getId()));
+
if(userData.isEmpty()){
user = User.builder()
.usernumber(String.valueOf(userInfo.getId()))
.role("USER")
-// .email(userInfo.getKakao_account().getEmail())
-// .nickname(userInfo.getKakao_account().getProfile().getNickname())
-// .userProfile(userInfo.getKakao_account().getProfile().getProfileImageUrl())
+ .profileImage(userInfo.getPicture())
.build();
+ early = true;
userRepository.save(user);
}
@@ -74,14 +71,13 @@ public TokenResponseDto googleLogin(String accessToken) {
TokenResponseDto tokenResponseDto = TokenResponseDto.builder()
.message("OK")
.code(200)
+ .early(early)
.accessToken(jwtTokenProvider.createAccessToken(
userLoginData.get().getId(),
String.valueOf(userLoginData.get().getRole())))
.refreshToken(refreshToken)
.build();
-// redisTemplate.opsForHash().put(jwtTokenProvider.createRereshToken(),"userId", String.valueOf(userLoginData.get().getId()));
-// redisTemplate.opsForHash().put(jwtTokenProvider.createRereshToken(),"role", String.valueOf(userLoginData.get().getRole()));
redisTemplate.opsForValue().set(String.valueOf(userLoginData.get().getId()),refreshToken);
@@ -95,13 +91,11 @@ public TokenResponseDto kakaoLogin(String accessToken) {
Mono userInfoMono = getUserKakaoInfo(accessToken);
KakaoUserResponseDto userInfo = userInfoMono.block();
-// LOGGER.info(String.valueOf(userInfo.getAccount_email()));
-// LOGGER.info(String.valueOf(userInfo.getProfile_nickname()));
-// LOGGER.info(String.valueOf(userInfo.getProfile_image()));
-// LOGGER.info(String.valueOf(userInfo.getKakao_account().getEmail()));
-// LOGGER.info(String.valueOf(userInfo.getKakao_account().getProfile().getProfileImageUrl()));
-// LOGGER.info(String.valueOf(userInfo.getKakao_account().getProfile().getNickname()));
+ log.info(String.valueOf(userInfo.getKakao_account().getEmail()));
+ log.info(String.valueOf(userInfo.getKakao_account().getProfile().getProfile_image_url()));
+ log.info(String.valueOf(userInfo.getKakao_account().getProfile().getNickname()));
+
Optional userData = userRepository.findByUsernumber(String.valueOf(userInfo.getId()));
@@ -109,11 +103,11 @@ public TokenResponseDto kakaoLogin(String accessToken) {
user = User.builder()
.usernumber(String.valueOf(userInfo.getId()))
.role("USER")
-// .email(userInfo.getKakao_account().getEmail())
-// .nickname(userInfo.getKakao_account().getProfile().getNickname())
-// .userProfile(userInfo.getKakao_account().getProfile().getProfileImageUrl())
+ .profileImage(userInfo.getKakao_account().getProfile().getProfile_image_url())
.build();
+ early = true;
+
userRepository.save(user);
}
@@ -125,14 +119,13 @@ public TokenResponseDto kakaoLogin(String accessToken) {
TokenResponseDto tokenResponseDto = TokenResponseDto.builder()
.message("OK")
.code(200)
+ .early(early)
.accessToken(jwtTokenProvider.createAccessToken(
userLoginData.get().getId(),
String.valueOf(userLoginData.get().getRole())))
.refreshToken(refreshToken)
.build();
-// redisTemplate.opsForHash().put(jwtTokenProvider.createRereshToken(),"userId", String.valueOf(userLoginData.get().getId()));
-// redisTemplate.opsForHash().put(jwtTokenProvider.createRereshToken(),"role", String.valueOf(userLoginData.get().getRole()));
redisTemplate.opsForValue().set(String.valueOf(userLoginData.get().getId()),refreshToken);
@@ -140,7 +133,6 @@ public TokenResponseDto kakaoLogin(String accessToken) {
return tokenResponseDto;
}
-
public Mono getUserKakaoInfo(String accessToken) {
return webClient
.get()