From 2bf099ee6d488f02e37dce0a8618580ccc97573b Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 17:01:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9sercurity=E7=9A=84User?= =?UTF-8?q?DetailsService=E7=9A=84=E5=AE=9E=E7=8E=B0=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cnbm/admin/service/impl/UserDetailsServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ym-admin/src/main/java/com/cnbm/admin/service/impl/UserDetailsServiceImpl.java b/ym-admin/src/main/java/com/cnbm/admin/service/impl/UserDetailsServiceImpl.java index a71bb7c..dcee45d 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/service/impl/UserDetailsServiceImpl.java +++ b/ym-admin/src/main/java/com/cnbm/admin/service/impl/UserDetailsServiceImpl.java @@ -11,6 +11,7 @@ import com.cnbm.admin.service.SysMenuService; import com.cnbm.common.utils.ConvertUtils; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.authentication.DisabledException; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; @@ -46,6 +47,9 @@ public class UserDetailsServiceImpl implements UserDetailsService { if (Objects.isNull(sysUserEntity)) { throw new UsernameNotFoundException("用户名不存在"); } + if (sysUserEntity.getStatus() == 0) { + throw new DisabledException("该账户已被禁用,请联系管理员"); + } log.info("sysUserEntity的值是"+sysUserEntity.toString()); log.info("sysUserEntity.getSuperAdmin()=="+sysUserEntity.getSuperAdmin()); Set userPermissions = sysMenuService.getUserPermissions(sysUserEntity);