diff --git a/motivoo-api/src/test/java/controller/OauthControllerTest.java b/motivoo-api/src/test/java/controller/OauthControllerTest.java index 15a61e5e..e472f535 100644 --- a/motivoo-api/src/test/java/controller/OauthControllerTest.java +++ b/motivoo-api/src/test/java/controller/OauthControllerTest.java @@ -30,9 +30,6 @@ import sopt.org.motivoo.api.controller.auth.dto.response.LoginResponse; import sopt.org.motivoo.api.controller.auth.dto.response.OauthTokenResponse; import sopt.org.motivoo.common.response.ApiResponse; -import sopt.org.motivoo.domain.auth.dto.request.OauthTokenCommand; -import sopt.org.motivoo.domain.auth.dto.response.LoginResult; -import sopt.org.motivoo.domain.auth.dto.response.OauthTokenResult; import sopt.org.motivoo.domain.user.repository.UserRepository; @Slf4j diff --git a/motivoo-api/src/test/java/fixture/UserFixture.java b/motivoo-api/src/test/java/fixture/UserFixture.java index 778cfd22..3f1a0c1f 100644 --- a/motivoo-api/src/test/java/fixture/UserFixture.java +++ b/motivoo-api/src/test/java/fixture/UserFixture.java @@ -63,7 +63,7 @@ public static User createUserV3(){ .nickname(USER_NICKNAME3) .socialId(SOCIAL_ID) .socialPlatform(USER_SOCIAL_PLATFORM3) - .socialAccessToken(SOCIAL_ACCESS_TOKEN) + // .socialAccessToken(SOCIAL_ACCESS_TOKEN) .refreshToken(REFRESH_TOKEN) .type(USER_TYPE3) .deleted(DELETED) @@ -87,7 +87,6 @@ public static LoginResponse createLoginResponse() { return LoginResponse.builder() .id(user.getSocialId()) .nickname(user.getNickname()) - .accessToken(user.getSocialAccessToken()) .refreshToken(user.getRefreshToken()) .tokenType("Bearer").build(); } diff --git a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/auth/service/OauthService.java b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/auth/service/OauthService.java index 18651ebb..45e62b97 100644 --- a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/auth/service/OauthService.java +++ b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/auth/service/OauthService.java @@ -90,18 +90,17 @@ public LoginResult login(OauthTokenCommand tokenRequest) { List userEntity = userRetriever.getUsersBySocialId(applePlatformMember.platformId()); //처음 로그인 하거나 탈퇴한 경우 -> 회원가입 if (userEntity == null || isWithdrawn(userEntity)) { - saveUser(null, applePlatformMember.platformId(), socialPlatform, tokenRequest, refreshToken); - } + User user = saveUser(null, applePlatformMember.platformId(), socialPlatform, tokenRequest, refreshToken); - //로그인 - User user = userEntity.get(0); - updateRefreshToken(user, refreshToken); - String accessToken = jwtTokenProvider.createAccessToken(new UserAuthentication(user.getId(),null,null)); + //로그인 + updateRefreshToken(user, refreshToken); + String accessToken = jwtTokenProvider.createAccessToken(new UserAuthentication(user.getId(),null,null)); - boolean isFinishedOnboarding = healthRetriever.existsHealthByUser(user); - boolean isMatched = user.getParentchild() != null && user.getParentchild().isMatched(); + boolean isFinishedOnboarding = healthRetriever.existsHealthByUser(user); + boolean isMatched = user.getParentchild() != null && user.getParentchild().isMatched(); - return LoginResult.of(userEntity.get(0), accessToken, refreshToken, isFinishedOnboarding, isMatched); + return LoginResult.of(user, accessToken, refreshToken, isFinishedOnboarding, isMatched); + } } throw new UserException(INVALID_SOCIAL_PLATFORM); } @@ -163,7 +162,7 @@ public User saveUser(String nickName, String providerId, SocialPlatform socialPl .nickname(nickName) .socialId(providerId) .socialPlatform(socialPlatform) - .socialAccessToken(tokenRequest.accessToken()) + // .socialAccessToken(tokenRequest.accessToken()) .refreshToken(refreshToken) .type(UserType.NONE) .deleted(Boolean.FALSE) diff --git a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/user/entity/User.java b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/user/entity/User.java index 228b8676..f5607492 100644 --- a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/user/entity/User.java +++ b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/user/entity/User.java @@ -64,7 +64,7 @@ public class User extends BaseTimeEntity { private String nickname; - private String socialAccessToken; + // private String socialAccessToken; private String refreshToken; @@ -83,12 +83,11 @@ public class User extends BaseTimeEntity { private final List userMissionChoice = new ArrayList<>(); @Builder - private User(String nickname, String socialId, SocialPlatform socialPlatform, String socialAccessToken, + private User(String nickname, String socialId, SocialPlatform socialPlatform, String refreshToken, UserType type, boolean deleted) { this.nickname = nickname; this.socialId = socialId; this.socialPlatform = socialPlatform; - this.socialAccessToken = socialAccessToken; this.refreshToken = refreshToken; this.type = type; this.deleted = deleted; @@ -131,7 +130,6 @@ public void updateOnboardingInfo(UserType type, Integer age) { public void deleteSocialInfo() { this.socialPlatform = SocialPlatform.WITHDRAW; - this.socialAccessToken = null; } public void updateParentchild(Parentchild parentchild) { diff --git a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/user/repository/UserRepository.java b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/user/repository/UserRepository.java index 9dd1d9ca..db653d53 100644 --- a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/user/repository/UserRepository.java +++ b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/user/repository/UserRepository.java @@ -28,9 +28,6 @@ public interface UserRepository extends JpaRepository { @Query("select u.refreshToken from User u where u.id=?1") String findRefreshTokenById(Long id); - @Query("select u.socialAccessToken from User u where u.id=?1") - String findSocialAccessTokenById(Long id); - @Query("select count(u.id) from User u where u.parentchild=?1") int countByParentchild(Parentchild parentchild); diff --git a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/user/repository/UserRetriever.java b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/user/repository/UserRetriever.java index a7c12d76..e077a5c9 100644 --- a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/user/repository/UserRetriever.java +++ b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/user/repository/UserRetriever.java @@ -38,9 +38,6 @@ public String getRefreshTokenById(Long userId) { return userRepository.findRefreshTokenById(userId); } - public String getAccessTokenById(Long userId) { - return userRepository.findSocialAccessTokenById(userId); - } public void saveUser(User newUser) { userRepository.save(newUser); diff --git a/motivoo-external/src/main/java/sopt/org/motivoo/external/client/auth/FeignClientConfig.java b/motivoo-external/src/main/java/sopt/org/motivoo/external/client/auth/FeignClientConfig.java index 3dda3e23..2a07c1a2 100644 --- a/motivoo-external/src/main/java/sopt/org/motivoo/external/client/auth/FeignClientConfig.java +++ b/motivoo-external/src/main/java/sopt/org/motivoo/external/client/auth/FeignClientConfig.java @@ -1,11 +1,17 @@ package sopt.org.motivoo.external.client.auth; import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import feign.Logger; import sopt.org.motivoo.external.MotivooExternalRoot; @Configuration @EnableFeignClients(basePackageClasses = MotivooExternalRoot.class) public class FeignClientConfig { + @Bean + Logger.Level feignLoggerLevel() { + return Logger.Level.FULL; + } } \ No newline at end of file diff --git a/motivoo-external/src/main/java/sopt/org/motivoo/external/client/auth/apple/service/AppleLoginService.java b/motivoo-external/src/main/java/sopt/org/motivoo/external/client/auth/apple/service/AppleLoginService.java index 1476ac85..370f95c6 100644 --- a/motivoo-external/src/main/java/sopt/org/motivoo/external/client/auth/apple/service/AppleLoginService.java +++ b/motivoo-external/src/main/java/sopt/org/motivoo/external/client/auth/apple/service/AppleLoginService.java @@ -29,7 +29,6 @@ public class AppleLoginService { public OAuthPlatformMemberResult getApplePlatformMember(String identityToken) { Map headers = appleJwtParser.parseHeaders(identityToken); ApplePublicKeys applePublicKeys = appleClient.getApplePublicKeys(); - PublicKey publicKey = publicKeyGenerator.generatePublicKey(headers, applePublicKeys); Claims claims = appleJwtParser.parsePublicKeyAndGetClaims(identityToken, publicKey); @@ -42,5 +41,4 @@ private void validateClaims(Claims claims) { throw new BusinessException(INVALID_APPLE_CLAIMS); } } - } \ No newline at end of file diff --git a/motivoo-external/src/main/java/sopt/org/motivoo/external/client/auth/apple/service/PublicKeyGenerator.java b/motivoo-external/src/main/java/sopt/org/motivoo/external/client/auth/apple/service/PublicKeyGenerator.java index 7f75b7d1..0c9d9ef0 100644 --- a/motivoo-external/src/main/java/sopt/org/motivoo/external/client/auth/apple/service/PublicKeyGenerator.java +++ b/motivoo-external/src/main/java/sopt/org/motivoo/external/client/auth/apple/service/PublicKeyGenerator.java @@ -3,6 +3,7 @@ import static sopt.org.motivoo.common.advice.CommonExceptionType.*; import org.springframework.stereotype.Component; + import sopt.org.motivoo.common.advice.BusinessException; import sopt.org.motivoo.external.client.auth.apple.ApplePublicKey; import sopt.org.motivoo.external.client.auth.apple.ApplePublicKeys; @@ -32,8 +33,8 @@ public PublicKey generatePublicKey(Map headers, ApplePublicKeys } private PublicKey generatePublicKeyWithApplePublicKey(ApplePublicKey publicKey) { - byte[] nBytes = Base64.getDecoder().decode(publicKey.getN()); - byte[] eBytes = Base64.getDecoder().decode(publicKey.getE()); + byte[] nBytes = Base64.getUrlDecoder().decode(publicKey.getN()); + byte[] eBytes = Base64.getUrlDecoder().decode(publicKey.getE()); BigInteger n = new BigInteger(POSITIVE_SIGN_NUMBER, nBytes); BigInteger e = new BigInteger(POSITIVE_SIGN_NUMBER, eBytes);