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 2ff69722..14b992ce 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 @@ -62,16 +62,11 @@ public BaseResponseDto kakaoLogin(String kakaoAccessToken) { @Transactional public BaseResponseDto logout(Long userId) { - redisTokenDelete(userId); + deleteredisToken(userId); log.info("로그아웃 완료"); return BaseResponseDto.of(SuccessCode.SUCCESS,null); } - - private void redisTokenDelete(Long userId){ - redisManager.deleteValueByKey(String.valueOf(userId)); - } - @Transactional public BaseResponseDto reissueToken(Long userId, String refreshToken) { @@ -84,6 +79,12 @@ public BaseResponseDto reissueToken(Long userId, String refres )); } + private void deleteredisToken(Long userId){ + redisManager.deleteValueByKey(String.valueOf(userId)); + } + private String getRedisToken(Long key){return redisManager.getValueByKey(key);} + + private User findUser(Long userId) { return userRepository.findUserData(Long.valueOf(userId)); } @@ -91,10 +92,12 @@ private User findUser(Long userId) { private void validateRefreshToken(Long userId, String refreshToken) { - String redisRefreshToken = redisManager.getValueByKey(userId); + 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/domain/user/controller/OnBoardingController.java b/src/main/java/com/modernfarmer/farmusspring/domain/user/controller/OnBoardingController.java index 222218e7..7ba63e6b 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.getUserId(), + User.createUserObject(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 15ec7bd7..5a8a6bbb 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 @@ -25,9 +25,7 @@ public class OnBoardingService { private final UserRepository userRepository; @Transactional - public BaseResponseDto settingMotivation(Long userId, SetMotivationRequest setMotivationRequest) { - - User user = findUser(userId); + public BaseResponseDto settingMotivation(User user, SetMotivationRequest setMotivationRequest) { insertMotivation(user, setMotivationRequest); @@ -57,7 +55,7 @@ private void updateCompleteBoarding(Long userId){ } - @Transactional + public void insertMotivation(User user, SetMotivationRequest setMotivationRequest) { for (String motivation : setMotivationRequest.getMotivation()) { insertOneMotivation(user, motivation); @@ -67,6 +65,7 @@ public void insertMotivation(User user, SetMotivationRequest setMotivationReques public void insertOneMotivation(User user, String motivation) { UserMotivation newMotivation = UserMotivation.createUserMotivation(motivation, user); user.addUserMotivation(newMotivation); + } private void insertLevel(Long userId, String level){ diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/user/service/UserService.java b/src/main/java/com/modernfarmer/farmusspring/domain/user/service/UserService.java index 7e1741f2..f39bd58b 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/user/service/UserService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/user/service/UserService.java @@ -86,10 +86,6 @@ private void updateProfileAndNickname(Long userId, String imageUrl, String nickn userRepository.selectProfileAndNickname(userId,imageUrl,nickname); } - - - - private Optional selectUser(Long userId){ Optional user = Optional.ofNullable(userRepository.findById(userId).orElseThrow(() -> new UserNotFoundException("해당 유저가 존재하지 않습니다."))); return user;