diff --git a/src/main/java/com/wooribound/global/exception/UserRegistrationApprovalException.java b/src/main/java/com/wooribound/global/exception/UserRegistrationApprovalException.java new file mode 100644 index 0000000..52a21e2 --- /dev/null +++ b/src/main/java/com/wooribound/global/exception/UserRegistrationApprovalException.java @@ -0,0 +1,5 @@ +package com.wooribound.global.exception; + +public class UserRegistrationApprovalException extends RuntimeException{ + public UserRegistrationApprovalException() {super("아직 가입승인 또는 탈퇴승인 처리중입니다. 관리자에게 문의해주세요.");} +} diff --git a/src/main/java/com/wooribound/global/security/userdetail/enterprise/EnterpriseUserDetailService.java b/src/main/java/com/wooribound/global/security/userdetail/enterprise/EnterpriseUserDetailService.java index e243c42..d760b23 100644 --- a/src/main/java/com/wooribound/global/security/userdetail/enterprise/EnterpriseUserDetailService.java +++ b/src/main/java/com/wooribound/global/security/userdetail/enterprise/EnterpriseUserDetailService.java @@ -5,6 +5,7 @@ import com.wooribound.global.constant.YN; import com.wooribound.global.constant.YNP; import com.wooribound.global.exception.DeletedUserException; +import com.wooribound.global.exception.UserRegistrationApprovalException; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationServiceException; @@ -27,6 +28,16 @@ public UserDetails loadUserByUsername(String userId) throws UsernameNotFoundExce Enterprise enterpriseUser = enterpriseUserRepository.findById(userId) .orElseThrow(() -> new UsernameNotFoundException("User not found: " + userId)); + if (enterpriseUser.getIsDeleted() == YNP.N && enterpriseUser.getUpdatedAt() == null) { + throw new AuthenticationServiceException("아직 가입승인 처리중입니다.", + new UserRegistrationApprovalException()); + } + + if (enterpriseUser.getIsDeleted() == YNP.P) { + throw new AuthenticationServiceException("아직 탈퇴승인 처리중입니다.", + new UserRegistrationApprovalException()); + } + if (enterpriseUser.getIsDeleted() == YNP.Y) { throw new AuthenticationServiceException("탈퇴한 기업 회원입니다.", new DeletedUserException("탈퇴한 기업 회원입니다. 회원가입을 새로 진행해 주세요"));