Skip to content

Commit

Permalink
Feat: 애플로그인 에러 메세지 수정 (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyukjinKimm authored Aug 18, 2024
1 parent 2bcc113 commit 0ac4335
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import com.donkeys_today.server.presentation.auth.dto.request.UserSignInRequest;
import com.donkeys_today.server.presentation.auth.dto.request.UserSignUpRequest;
import com.donkeys_today.server.support.dto.type.ErrorType;
import com.donkeys_today.server.support.exception.BusinessException;
import com.donkeys_today.server.support.exception.NotFoundException;
import com.donkeys_today.server.support.exception.UnauthorizedException;
import com.donkeys_today.server.support.exception.auth.SignInException;
import com.donkeys_today.server.support.exception.auth.SignUpException;
import com.donkeys_today.server.support.feign.apple.AppleFeignClient;
import com.donkeys_today.server.support.feign.apple.AppleIdentityTokenParser;
import com.donkeys_today.server.support.feign.apple.AppleIdentityTokenValidator;
Expand Down Expand Up @@ -62,13 +62,13 @@ public User signIn(UserSignInRequest userSignInRequest, String idTokenWithBearer

private User findByPlatformAndPlatformId(Platform platform, String platformId) {
return userRepository.findByPlatformAndPlatformID(platform, platformId).orElseThrow(
() -> new NotFoundException(ErrorType.DUPLICATED_USER_ERROR)
() -> new SignInException(ErrorType.USER_NOT_FOUND)
);
}

private void validateDuplicateUser(String userId) {
if (userRepository.existsByPlatformAndPlatformID(Platform.APPLE, userId)) {
throw new BusinessException(ErrorType.DUPLICATED_USER_ERROR);
throw new SignUpException(ErrorType.DUPLICATED_USER_ERROR);
}
}

Expand All @@ -81,7 +81,6 @@ public String getApplePlatformId(String identityToken) {
ApplePublicKeys applePublicKeys = appleFeignClient.getApplePublicKeys();
PublicKey publicKey = applePublicKeyGenerator.generatePublicKeyWithApplePublicKeys(headers, applePublicKeys);
Claims claims = appleIdentityTokenParser.parseWithPublicKeyAndGetClaims(identityToken, publicKey);
System.out.println(claims.toString());
validateClaims(claims);

return claims.getSubject();
Expand All @@ -92,5 +91,4 @@ private void validateClaims(Claims claims) {
throw new UnauthorizedException(ErrorType.INVALID_ID_TOKEN);
}
}

}

0 comments on commit 0ac4335

Please sign in to comment.