Skip to content
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 @@ -16,12 +16,21 @@ public class OAuthUserPersistenceProcessor implements StepProcessor<OAuthUserInf

private final UserJpaRepository userRepository;

/**
* this method is processing OAuthUserInfo to UserJpaEntity that is Get or Create.
*
* @param info
* @return
*/
Comment on lines +19 to +24

Choose a reason for hiding this comment

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

medium

Javadoc의 가독성을 높이기 위해 내용을 조금 더 명확하게 수정하는 것을 제안합니다. 예를 들어, 현재의 'this method is processing...' 대신 메서드의 역할을 명확히 설명하고 파라미터와 반환 값에 대한 설명도 추가하면 좋겠습니다.

Suggested change
/**
* this method is processing OAuthUserInfo to UserJpaEntity that is Get or Create.
*
* @param info
* @return
*/
/**
* 주어진 OAuthUserInfo를 처리하여 기존 사용자를 찾거나 새로 생성합니다.
*
* @param info OAuth 사용자 정보
* @return 조회 또는 생성된 사용자 엔티티
*/

@Override
@Transactional
public UserJpaEntity process(final OAuthUserInfo info) {
return userRepository.findByPhoneNumber(
PhoneNumberUtil.formatPhoneNumber(info.phoneNumber()))
.map(existingUser -> {
// if (existingUser.isMosuUser()) {
// throw new IllegalArgumentException("이미 모수 회원입니다.");
// }
Comment on lines +31 to +33

Choose a reason for hiding this comment

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

medium

주석 처리된 코드가 남아있습니다. 이 로직은 OAuthUserService로 이동되었으므로, 혼동을 피하고 코드를 깔끔하게 유지하기 위해 이 주석 블록을 제거하는 것이 좋습니다.

existingUser.updateOAuthUser(
info.gender(),
info.name(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.Map;
import life.mosu.mosuserver.domain.profile.repository.ProfileJpaRepository;
import life.mosu.mosuserver.domain.user.entity.UserJpaEntity;
import life.mosu.mosuserver.global.exception.CustomRuntimeException;
import life.mosu.mosuserver.global.exception.ErrorCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.ParameterizedTypeReference;
Expand Down Expand Up @@ -58,7 +60,10 @@ public OAuth2User loadUser(final OAuth2UserRequest userRequest)
oAuth2UserAttributes, agreedToMarketing);

final UserJpaEntity oAuthUser = oAuthUserPersistenceProcessor.process(userInfo);
log.info("OAuthUser: {}", oAuthUser);
if (oAuthUser.isMosuUser()) {
log.info("모수 회원으로 가입된 사용자입니다: {}", oAuthUser.getLoginId());
throw new CustomRuntimeException(ErrorCode.ALREADY_MOSU_USER);
}
Boolean isProfileRegistered = profileRepository.existsByUserId(oAuthUser.getId());

return new OAuthUser(oAuthUser, oAuth2UserAttributes, userNameAttributeName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
@Getter
@RequiredArgsConstructor
public enum ErrorCode {

// Principal 관련 에러
ALREADY_MOSU_USER(HttpStatus.BAD_REQUEST, "이미 모수 회원입니다."),
PRINCIPAL_NOT_FOUND(HttpStatus.UNAUTHORIZED, "인증된 사용자를 찾을 수 없습니다."),
LOGIN_BLOCKED(HttpStatus.UNAUTHORIZED, "로그인 시도가 차단되었습니다. 잠시 후 다시 시도해주세요."),
TOO_MANY_REQUESTS(HttpStatus.TOO_MANY_REQUESTS, "요청이 너무 많습니다. 잠시 후 다시 시도해주세요."),
Expand Down