Skip to content

Commit

Permalink
Merge pull request #154 from WooRibound/fix/#143-test
Browse files Browse the repository at this point in the history
[update] #143 - 기업 로그인 시 예외처리 로직 추가
  • Loading branch information
haewoni authored Nov 28, 2024
2 parents 9579606 + 63004c3 commit b7be394
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.wooribound.global.exception;

public class UserRegistrationApprovalException extends RuntimeException{
public UserRegistrationApprovalException() {super("아직 가입승인 또는 탈퇴승인 처리중입니다. 관리자에게 문의해주세요.");}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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("탈퇴한 기업 회원입니다. 회원가입을 새로 진행해 주세요"));
Expand Down

0 comments on commit b7be394

Please sign in to comment.