diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java index 1551e98..4eb4bbe 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java @@ -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; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/agent/AgentLoginUserDetailService.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/agent/AgentLoginUserDetailService.java index cce479d..d3234b2 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/agent/AgentLoginUserDetailService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/agent/AgentLoginUserDetailService.java @@ -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()); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/common/CommonLoginUserDetailService.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/common/CommonLoginUserDetailService.java index 9878d4a..6679760 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/common/CommonLoginUserDetailService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/common/CommonLoginUserDetailService.java @@ -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()); 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 fd1e859..20854a9 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 @@ -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); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java index f4291be..ae0261e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java @@ -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