From 3e56b7277ede2e1773f72495f399e937839dcdc0 Mon Sep 17 00:00:00 2001 From: seungryeol Date: Sun, 26 May 2024 15:34:52 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[fix]=20=EC=98=A8=EB=B3=B4=EB=94=A9=20?= =?UTF-8?q?=EB=8F=99=EA=B8=B0=20=EC=B6=94=EA=B0=80=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/controller/OnBoardingController.java | 2 +- .../domain/user/service/OnBoardingService.java | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/user/controller/OnBoardingController.java b/src/main/java/com/modernfarmer/farmusspring/domain/user/controller/OnBoardingController.java index 7ba63e6b..222218e7 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/user/controller/OnBoardingController.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/user/controller/OnBoardingController.java @@ -30,7 +30,7 @@ public BaseResponseDto settingMotivation(@AuthenticationPrincipal CustomUs @Validated @RequestBody SetMotivationRequest setMotivationRequest ) { return onBoardingService.settingMotivation( - User.createUserObject(user.getUserId()), + user.getUserId(), setMotivationRequest); } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/user/service/OnBoardingService.java b/src/main/java/com/modernfarmer/farmusspring/domain/user/service/OnBoardingService.java index 3c87807e..a920f567 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/user/service/OnBoardingService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/user/service/OnBoardingService.java @@ -24,27 +24,23 @@ public class OnBoardingService { private final UserRepository userRepository; @Transactional - public BaseResponseDto settingMotivation(User user, SetMotivationRequest setMotivationRequest) { + public BaseResponseDto settingMotivation(Long userId, SetMotivationRequest setMotivationRequest) { + User user = findUser(userId); insertMotivation(user, setMotivationRequest); - return BaseResponseDto.of(SuccessCode.SUCCESS,null); } @Transactional public BaseResponseDto settingLevel(Long userId, SetLevelRequest setLevelRequest){ String level = measureLevel(setLevelRequest.getTime(), setLevelRequest.getSkill()); - insertLevel(userId, level); - return BaseResponseDto.of(SuccessCode.SUCCESS, SetLevelResponse.of(level)); } @Transactional public BaseResponseDto completeOnBoarding(Long userId) { - updateCompleteBoarding(userId); - return BaseResponseDto.of(SuccessCode.SUCCESS, null); } @@ -78,7 +74,6 @@ private String measureLevel(int time,String skill) { boolean isElementary = false; boolean isBeginner = false; - if ("홈파밍 중급".equals(skill)) { isIntermediate = true; } else if ("홈파밍 고수".equals(skill)) { @@ -89,7 +84,6 @@ private String measureLevel(int time,String skill) { isBeginner = true; } - if (time == 2 && (isIntermediate || isMaster)) { return "HARD"; } else if (time == 2 && (isBeginner || isElementary)) { @@ -107,7 +101,6 @@ private String measureLevel(int time,String skill) { } else if (time == 0 && (isElementary || isBeginner)) { return "EASY"; } - return "알 수 없음"; } From ed22beb883a298cb29127f7760bd40452edb9456 Mon Sep 17 00:00:00 2001 From: seungryeol Date: Sun, 26 May 2024 15:35:16 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[fix]=20=ED=86=A0=ED=81=B0=20=EC=9E=AC?= =?UTF-8?q?=EB=B0=9C=EA=B8=89=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/auth/service/AuthService.java | 19 +++---------------- .../common/security/JwtTokenProvider.java | 1 + 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/auth/service/AuthService.java b/src/main/java/com/modernfarmer/farmusspring/domain/auth/service/AuthService.java index 14b992ce..3bf42ff5 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/auth/service/AuthService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/auth/service/AuthService.java @@ -33,35 +33,27 @@ public class AuthService { private final JwtTokenProvider jwtTokenProvider; - private final RedisManager redisManager; - private final UserRepository userRepository; - private final GoogleLogin googleLogin; - private final KakaoLogin kakaoLogin; @Transactional public BaseResponseDto googleLogin(String googleAccessToken) { return BaseResponseDto.of(SuccessCode.SUCCESS, - googleLogin.loginMethod(googleAccessToken) - - ); + googleLogin.loginMethod(googleAccessToken)); } @Transactional public BaseResponseDto kakaoLogin(String kakaoAccessToken) { return BaseResponseDto.of(SuccessCode.SUCCESS, - kakaoLogin.loginMethod(kakaoAccessToken) - ); + kakaoLogin.loginMethod(kakaoAccessToken)); } @Transactional public BaseResponseDto logout(Long userId) { - deleteredisToken(userId); log.info("로그아웃 완료"); return BaseResponseDto.of(SuccessCode.SUCCESS,null); @@ -75,8 +67,7 @@ public BaseResponseDto reissueToken(Long userId, String refres return BaseResponseDto.of(SuccessCode.SUCCESS, TokenResponseDto.of( jwtTokenProvider.createAccessToken(Long.valueOf(userId), user.getRole()), - refreshToken - )); + refreshToken)); } private void deleteredisToken(Long userId){ @@ -91,13 +82,9 @@ private User findUser(Long userId) { private void validateRefreshToken(Long userId, String refreshToken) { - String redisRefreshToken = getRedisToken(userId); if (!refreshToken.equals(redisRefreshToken)) { - throw new AuthRefreshTokenValidateException("일치하지 않는 토큰입니다."); } } - - } \ No newline at end of file diff --git a/src/main/java/com/modernfarmer/farmusspring/global/common/security/JwtTokenProvider.java b/src/main/java/com/modernfarmer/farmusspring/global/common/security/JwtTokenProvider.java index 1f0242da..11934cf5 100644 --- a/src/main/java/com/modernfarmer/farmusspring/global/common/security/JwtTokenProvider.java +++ b/src/main/java/com/modernfarmer/farmusspring/global/common/security/JwtTokenProvider.java @@ -34,6 +34,7 @@ public class JwtTokenProvider { private final long accessTokenTime = 60L * 1000 * 10000000; private final long refreshTokenTime = 180L * 1000 * 1000000000; + @PostConstruct protected void init() { log.info("[init] JwtTokenProvider 내 secretKey 초기화 시작", StandardCharsets.UTF_8);