From 89aae12b020a25f3a5d7a461acde7280d344d0d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?niohe=C2=B7erbao?= Date: Tue, 4 Apr 2023 11:20:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=89=B4=E6=9D=83=E8=B0=83=E6=95=B4=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/credential/CredentialLoginUserDetailService.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java index 6cbfdfd..1d4ca2a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java @@ -6,6 +6,7 @@ import com.ningdatech.pmapi.user.manage.UserAuthLoginManage; import com.ningdatech.pmapi.user.security.auth.constants.UserDeatilsServiceConstant; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; +import com.ningdatech.pmapi.user.security.auth.validate.CommonLoginException; import lombok.RequiredArgsConstructor; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; @@ -35,14 +36,23 @@ public class CredentialLoginUserDetailService implements UserDetailsService { switch (loginTypeEnum) { case PHONE_VERIFICATION_CODE_LOGIN: { userFullInfoDTO = userAuthLoginManage.queryUserInfoInPhoneNoAuth(username); + if (Objects.isNull(userFullInfoDTO)) { + throw new CommonLoginException("改手机号未绑定用户"); + } } break; case USERNAME_PASSWORD_LOGIN: { userFullInfoDTO = userAuthLoginManage.queryUserInfoInPasswordAuth(username); + if (Objects.isNull(userFullInfoDTO)) { + throw new UsernameNotFoundException(String.format("%s user not exist", username)); + } } break; case DING_QR_LOGIN: { userFullInfoDTO = userAuthLoginManage.queryUserInfoInAccountIdAuth(username); + if (Objects.isNull(userFullInfoDTO)) { + throw new CommonLoginException("浙政钉账号无法登陆"); + } } break; default: { @@ -50,9 +60,6 @@ public class CredentialLoginUserDetailService implements UserDetailsService { } } - if (Objects.isNull(userFullInfoDTO)) { - throw new UsernameNotFoundException(String.format("%s user not exist", username)); - } UserInfoDetails userInfoDetails = new UserInfoDetails(); userInfoDetails.setUserId(userFullInfoDTO.getUserId()); userInfoDetails.setUsername(userFullInfoDTO.getUsername());