Explorar el Código

鉴权调整优化

tags/24080901
niohe·erbao hace 1 año
padre
commit
89aae12b02
Se han modificado 1 ficheros con 10 adiciones y 3 borrados
  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 Ver fichero

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


Cargando…
Cancelar
Guardar