Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[update] #143 - 기업 로그인 시 예외처리 로직 추가 #154

Merged
merged 1 commit into from
Nov 28, 2024
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
@@ -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