fix: 修改sercurity的UserDetailsService的实现类
This commit is contained in:
parent
62d1a761cc
commit
2bf099ee6d
@ -11,6 +11,7 @@ import com.cnbm.admin.service.SysMenuService;
|
|||||||
import com.cnbm.common.utils.ConvertUtils;
|
import com.cnbm.common.utils.ConvertUtils;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
@ -46,6 +47,9 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
|||||||
if (Objects.isNull(sysUserEntity)) {
|
if (Objects.isNull(sysUserEntity)) {
|
||||||
throw new UsernameNotFoundException("用户名不存在");
|
throw new UsernameNotFoundException("用户名不存在");
|
||||||
}
|
}
|
||||||
|
if (sysUserEntity.getStatus() == 0) {
|
||||||
|
throw new DisabledException("该账户已被禁用,请联系管理员");
|
||||||
|
}
|
||||||
log.info("sysUserEntity的值是"+sysUserEntity.toString());
|
log.info("sysUserEntity的值是"+sysUserEntity.toString());
|
||||||
log.info("sysUserEntity.getSuperAdmin()=="+sysUserEntity.getSuperAdmin());
|
log.info("sysUserEntity.getSuperAdmin()=="+sysUserEntity.getSuperAdmin());
|
||||||
Set<String> userPermissions = sysMenuService.getUserPermissions(sysUserEntity);
|
Set<String> userPermissions = sysMenuService.getUserPermissions(sysUserEntity);
|
||||||
|
Loading…
Reference in New Issue
Block a user