Skip to content

Commit

Permalink
Fix: oauth 로그인 시 회원을 찾지 못한 경우에 반환하는 에러 타입을 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
WonSteps committed Nov 18, 2024
1 parent f134e93 commit 34ca94e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import com.dnd.runus.domain.member.SocialProfileRepository;
import com.dnd.runus.global.constant.MemberRole;
import com.dnd.runus.global.constant.SocialType;
import com.dnd.runus.global.exception.NotFoundException;
import com.dnd.runus.global.exception.BusinessException;
import com.dnd.runus.global.exception.type.ErrorType;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -30,7 +31,8 @@ public boolean isSocialMemberExists(SocialType socialType, String oauthId, long
public SocialProfile findOrThrow(SocialType socialType, String oauthId, String email) {
SocialProfile socialProfile = socialProfileRepository
.findBySocialTypeAndOauthId(socialType, oauthId)
.orElseThrow(() -> new NotFoundException(SocialProfile.class, oauthId));
.orElseThrow(() ->
new BusinessException(ErrorType.SOCIAL_MEMBER_NOT_FOUND, socialType + ", oauthId: " + oauthId));

updateEmailIfChanged(socialProfile, email);
return socialProfile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public enum ErrorType {
INVALID_CREDENTIALS(UNAUTHORIZED, DEBUG, "AUTH_008", "해당 사용자의 정보가 없거나 일치하지 않아 처리할 수 없습니다"),

// OauthErrorType
USER_NOT_FOUND(NOT_FOUND, DEBUG, "OAUTH_001", "존재하지 않은 사용자 입니다"),
SOCIAL_MEMBER_NOT_FOUND(NOT_FOUND, DEBUG, "OAUTH_001", "찾을 수 없는 소셜 회원입니다"),

// DatabaseErrorType
ENTITY_NOT_FOUND(NOT_FOUND, DEBUG, "DB_001", "해당 엔티티를 찾을 수 없습니다"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class OauthController {
""")
@ApiErrorType({
ErrorType.UNSUPPORTED_SOCIAL_TYPE,
ErrorType.USER_NOT_FOUND,
ErrorType.SOCIAL_MEMBER_NOT_FOUND,
ErrorType.FAILED_AUTHENTICATION,
ErrorType.UNSUPPORTED_JWT_TOKEN
})
Expand Down

0 comments on commit 34ca94e

Please sign in to comment.