Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Validation 적용 - #107 #129

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ private User getUserByUserId(final long userId) {
}

//태그 리스트 사이즈 검증
private void validateUserTagSize(final List<DateTagType> userTags) {
public void validateUserTagSize(final List<DateTagType> userTags) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지리네용

if (userTags.isEmpty() || userTags.size() > 3) {
throw new InvalidValueException((FailureCode.WRONG_USER_TAG_SIZE));
}
}

private RefreshToken getRefreshTokenByToken(final String refreshToken) {
try {
return refreshTokenRepository.findByToken(refreshToken)
return refreshTokenRepository.findRefreshTokenByToken(refreshToken)
.orElseThrow(() -> new UnauthorizedException(FailureCode.UNAUTHORIZED));
} catch (IllegalArgumentException e) {
log.error(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
@RequiredArgsConstructor
public class UserService {

private final AuthService authService;
@Value("${aws-property.s3-bucket-name}")
private String path;

Expand Down Expand Up @@ -59,6 +60,7 @@ public void editUserProfile(final Long userId,

//tag 변경
userTagRepository.deleteAllByUserId(foundUser.getId());
authService.validateUserTagSize(tags);
saveUserTag(foundUser, tags);

//이미지 변경
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

@Repository
public interface AdvertisementRepository extends JpaRepository<Advertisement, Long> {
@Query("SELECT a FROM advertisements a ORDER BY a.createdAt DESC")
@Query("SELECT a FROM Advertisement a ORDER BY a.createdAt DESC")
List<Advertisement> findTop5ByOrderByCreatedDateDesc(Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public interface RefreshTokenRepository extends JpaRepository<RefreshToken, String> {

Optional<RefreshToken> findByToken(String token);
Optional<RefreshToken> findRefreshTokenByToken(String token);

void deleteRefreshTokenByUserId(final Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class AppleFeignProvider {
private final AppleClientSecretGenerator appleClientSecretGenerator;
private final AppleProperties appleProperties;

//AuthService에서 호출
public String getApplePlatformUserId(final String identityToken) {
Map<String, String> tokenHeaders = appleIdentityJWTParser.parseHeader(identityToken);
ApplePublicKeys applePublicKey = appleFeignApi.getApplePublicKeys();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
public class AppleIdentityJWTParser {
private final ObjectMapper objectMapper;
private static final int HEADER_INDEX = 0;
private static final String SPLIYBY = "\\.";

public Map<String, String> parseHeader(final String identityToken) {
try {

//헤더, 페이로드, 서명에서 첫 인덱스인 헤더를 가져옴
String encodedHeader = identityToken.split("\\.")[HEADER_INDEX];
String encodedHeader = identityToken.split(SPLIYBY)[HEADER_INDEX];
String decodedHeader = new String(Base64.getUrlDecoder().decode(encodedHeader), StandardCharsets.UTF_8);
return objectMapper.readValue(decodedHeader, Map.class);
} catch (JsonProcessingException | ArrayIndexOutOfBoundsException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class KakaoFeignProvider {
private final KakaoFeignApi kakaoFeignApi;
private final ObjectMapper objectMapper;

private final String TARGETIDTYPE = "user_id";
private static final String TARGETIDTYPE = "user_id";

//AuthService에서 호출 : 카카오에서 주는 userId 받아오기
public String getKakaoPlatformUserId(final String kakaoAccessToken) {
Expand All @@ -31,7 +31,7 @@ public String getKakaoPlatformUserId(final String kakaoAccessToken) {

//AuthService에서 호출 : 회원탈퇴 할 때, 카카오톡과 연결 끊기
public void unLinkWithKakao(final String kakaoPlatformUserId) {
String kakaoRequestHeader = getKakaoRequestHeader(KakaoRequestType.UN_LINK, kakaoPlatformUserId);
String kakaoRequestHeader = getKakaoRequestHeader(KakaoRequestType.UN_LINK, null);
try {
kakaoFeignApi.unlink(kakaoRequestHeader, TARGETIDTYPE, Long.valueOf(kakaoPlatformUserId));
} catch (FeignException e) {
Expand Down

This file was deleted.

Loading