From 97756c916b883444e57587af1bea4ab1acfd3de2 Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期四, 17 二月 2022 14:34:49 +0800 Subject: [PATCH] [update] 新增顧問狀態,利於後臺管理 --- pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java b/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java index 54391f0..6000438 100644 --- a/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java +++ b/pamapi/src/main/java/com/pollex/pam/security/provider/EServiceAuthenticationProvider.java @@ -4,10 +4,12 @@ import com.pollex.pam.config.ApplicationProperties; import com.pollex.pam.domain.Consultant; import com.pollex.pam.enums.ConsultantDetailEnum; +import com.pollex.pam.enums.ConsultantStatusEnum; import com.pollex.pam.repository.ConsultantRepository; import com.pollex.pam.security.token.EServiceAuthenticationToken; import com.pollex.pam.service.LoginRecordService; import com.pollex.pam.service.dto.EServiceResponse; +import com.pollex.pam.web.rest.errors.ConsultantDisableException; import com.pollex.pam.web.rest.errors.EServiceErrorException; import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; @@ -38,6 +40,8 @@ import java.security.NoSuchAlgorithmException; import java.security.cert.X509Certificate; import java.util.*; + +import static com.pollex.pam.enums.ConsultantStatusEnum.DISABLE; @Component public class EServiceAuthenticationProvider { @@ -87,9 +91,13 @@ } } - private UsernamePasswordAuthenticationToken getConsultantToken(String account, String credential) { + private UsernamePasswordAuthenticationToken getConsultantToken(String account, String credential) throws ConsultantDisableException { Consultant consultant = consultantRepository.findOneByAgentNo(account).orElseThrow(() -> new UsernameNotFoundException("閰脤“����蒂銝��慦�像�蝟餌絞銝�")); + if(consultant.getStatus() == DISABLE) { + throw new ConsultantDisableException(); + } + List<GrantedAuthority> grantedAuths = Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")); UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(account, credential, grantedAuths); -- Gitblit v1.8.0