Browse Source

鉴权调整优化

tags/24080901
niohe·erbao 1 year ago
parent
commit
89aae12b02
1 changed files with 10 additions and 3 deletions
  1. +10
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java

+ 10
- 3
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java View File

@@ -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());


Loading…
Cancel
Save