Skip to content

Commit

Permalink
fix: 다른 사용자 프로필이 내 프로필로 조회되는 버그
Browse files Browse the repository at this point in the history
  • Loading branch information
jang-namu committed May 16, 2024
1 parent b613010 commit 59da874
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ public ProfileResponse getMyProfile(UserDetails userDetails) {
}

public ProfileResponse getOthersProfile(String nickname) {
User user = userRepository.findByNickname(nickname)
User targetUser = userRepository.findByNickname(nickname)
.orElseThrow(() -> new ResourceNotFoundException(Errors.USER_NOT_FOUND));
Profile profile = profileRepository.findByUserUserId(user.getUserId())
Profile profile = profileRepository.findByUserUserId(targetUser.getUserId())
.orElseThrow(() -> new ResourceNotFoundException(Errors.PROFILE_NOT_FOUND));

return ProfileResponse.of(user, profile);
return ProfileResponse.of(targetUser, profile);
}

public ProfileResponse getOthersProfile(String nickname, UserDetails userDetails) {
User user = ((CustomUserDetails) userDetails).getUser();
User targetUser = userRepository.findByNickname(nickname)
.orElseThrow(() -> new ResourceNotFoundException(Errors.USER_NOT_FOUND));
Profile profile = profileRepository.findByUserUserId(user.getUserId())
Profile profile = profileRepository.findByUserUserId(targetUser.getUserId())
.orElseThrow(() -> new ResourceNotFoundException(Errors.PROFILE_NOT_FOUND));
boolean followed = followRepository.existsByFollowerAndFollowing(user, targetUser);

Expand Down

0 comments on commit 59da874

Please sign in to comment.