Bläddra i källkod

fix 禁用用户无法登陆

tags/24080901
niohe·erbao 1 år sedan
förälder
incheckning
ae4a241413
5 ändrade filer med 29 tillägg och 0 borttagningar
  1. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java
  2. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/agent/AgentLoginUserDetailService.java
  3. +5
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/common/CommonLoginUserDetailService.java
  4. +5
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java
  5. +7
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java

+ 6
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java Visa fil

@@ -13,6 +13,7 @@ import com.ningdatech.pmapi.sys.mapper.RoleMapper;
import com.ningdatech.pmapi.sys.model.entity.Role;
import com.ningdatech.pmapi.sys.model.entity.UserRole;
import com.ningdatech.pmapi.sys.service.IUserRoleService;
import com.ningdatech.pmapi.user.constant.UserAvailableEnum;
import com.ningdatech.pmapi.user.entity.UserInfo;
import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
@@ -118,6 +119,11 @@ public class UserInfoHelperImpl implements UserInfoHelper {
userFullInfo.setUsername(userInfo.getRealName());
userFullInfo.setMobile(userInfo.getMobile());
userFullInfo.setAccountId(userInfo.getAccountId());

String available = userInfo.getAvailable();
if (StringUtils.isNotBlank(available)) {
userFullInfo.setAvailable(UserAvailableEnum.valueOf(available));
}
return userFullInfo;
}



+ 6
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/agent/AgentLoginUserDetailService.java Visa fil

@@ -2,8 +2,10 @@ package com.ningdatech.pmapi.user.security.auth.agent;


import com.ningdatech.pmapi.common.helper.UserInfoHelper;
import com.ningdatech.pmapi.user.constant.UserAvailableEnum;
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;
@@ -32,6 +34,10 @@ public class AgentLoginUserDetailService implements UserDetailsService {
if (Objects.isNull(userFullInfoDTO)) {
throw new UsernameNotFoundException(String.format("%s user not exist", username));
}
if (UserAvailableEnum.DISABLE.equals(userFullInfoDTO.getAvailable())) {
throw new CommonLoginException("该账号已被禁用");
}

UserInfoDetails userInfoDetails = new UserInfoDetails();
userInfoDetails.setUserId(userFullInfoDTO.getUserId());
userInfoDetails.setUsername(userFullInfoDTO.getUsername());


+ 5
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/common/CommonLoginUserDetailService.java Visa fil

@@ -1,9 +1,11 @@
package com.ningdatech.pmapi.user.security.auth.common;


import com.ningdatech.pmapi.user.constant.UserAvailableEnum;
import com.ningdatech.pmapi.user.manage.UserInfoManage;
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;
@@ -30,6 +32,9 @@ public class CommonLoginUserDetailService implements UserDetailsService {
if (Objects.isNull(userFullInfoDTO)) {
throw new UsernameNotFoundException(String.format("%s user not exist", username));
}
if (UserAvailableEnum.DISABLE.equals(userFullInfoDTO.getAvailable())) {
throw new CommonLoginException("该账号已被禁用");
}
UserInfoDetails userInfoDetails = new UserInfoDetails();
userInfoDetails.setUserId(userFullInfoDTO.getUserId());
userInfoDetails.setUsername(userFullInfoDTO.getUsername());


+ 5
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java Visa fil

@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.user.security.auth.credential;


import com.ningdatech.pmapi.user.constant.LoginTypeEnum;
import com.ningdatech.pmapi.user.constant.UserAvailableEnum;
import com.ningdatech.pmapi.user.convert.UserInfoConvertor;
import com.ningdatech.pmapi.user.manage.UserInfoManage;
import com.ningdatech.pmapi.user.security.auth.constants.UserDeatilsServiceConstant;
@@ -60,6 +61,10 @@ public class CredentialLoginUserDetailService implements UserDetailsService {
throw new UsernameNotFoundException(String.format("%s user not exist", username));
}
}

if (UserAvailableEnum.DISABLE.equals(userFullInfo.getAvailable())) {
throw new CommonLoginException("该账号已被禁用");
}
return UserInfoConvertor.toUserInfoDetails(userFullInfo);
}
}

+ 7
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java Visa fil

@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.user.security.auth.model;

import cn.hutool.core.collection.CollUtil;
import com.ningdatech.pmapi.sys.model.entity.Role;
import com.ningdatech.pmapi.user.constant.UserAvailableEnum;
import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum;
import lombok.Data;

@@ -74,6 +75,12 @@ public class UserFullInfoDTO {
private Long accountId;

/**
* 用户是否可用
*/
private UserAvailableEnum available;


/**
* 取最高的权限
*
* @return


Laddar…
Avbryt
Spara