Skip to content

Commit

Permalink
Merge pull request #23 from Mojacknong/bug_22/User도메인-수정
Browse files Browse the repository at this point in the history
Bug 22/user도메인 수정
  • Loading branch information
MinchoGreenT authored May 26, 2024
2 parents b78424b + 66c49f3 commit cc588c0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<LoginResponseDto> googleLogin(String googleAccessToken) {

return BaseResponseDto.of(SuccessCode.SUCCESS,
googleLogin.loginMethod(googleAccessToken)

);
googleLogin.loginMethod(googleAccessToken));
}
@Transactional
public BaseResponseDto<LoginResponseDto> kakaoLogin(String kakaoAccessToken) {

return BaseResponseDto.of(SuccessCode.SUCCESS,
kakaoLogin.loginMethod(kakaoAccessToken)
);
kakaoLogin.loginMethod(kakaoAccessToken));


}
@Transactional
public BaseResponseDto<Void> logout(Long userId) {

deleteredisToken(userId);
log.info("로그아웃 완료");
return BaseResponseDto.of(SuccessCode.SUCCESS,null);
Expand All @@ -75,8 +67,7 @@ public BaseResponseDto<TokenResponseDto> 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){
Expand All @@ -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("일치하지 않는 토큰입니다.");
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public BaseResponseDto<Void> settingMotivation(@AuthenticationPrincipal CustomUs
@Validated @RequestBody SetMotivationRequest setMotivationRequest
) {
return onBoardingService.settingMotivation(
User.createUserObject(user.getUserId()),
user.getUserId(),
setMotivationRequest);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,23 @@ public class OnBoardingService {
private final UserRepository userRepository;

@Transactional
public BaseResponseDto<Void> 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<SetLevelResponse> 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<Void> completeOnBoarding(Long userId) {

updateCompleteBoarding(userId);

return BaseResponseDto.of(SuccessCode.SUCCESS, null);
}

Expand Down Expand Up @@ -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)) {
Expand All @@ -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)) {
Expand All @@ -107,7 +101,6 @@ private String measureLevel(int time,String skill) {
} else if (time == 0 && (isElementary || isBeginner)) {
return "EASY";
}

return "알 수 없음";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cc588c0

Please sign in to comment.