Spring Security [Spring Boot App]:如何阻止用户?

时间:2017-04-06 10:14:38

标签: spring-boot spring-security

我的项目是员工退出流程,一旦员工放心,预计会阻止员工登录而不是删除员工。

尝试:

  1. userObject.isCredentialsNonExpired() = false
  2. userObject.isAccountNonLocked() = false
  3. userObject.isAccountNonExpired() = false
  4. userObject.isEnabled() = false
  5. 即使我修改了所有这四个值,登录仍然适用于用户。

    @Autowired 
    EmployeeRepository empRep; 
    
    @Override 
    public EmployeeEntity loadUserByUsername(String username) throws UsernameNotFoundException { 
        EmployeeEntity emp = empRep.findByUserId(username); 
        if (emp == null) { 
            throw new UsernameNotFoundException("User trapped in singularity"); 
        } 
        return emp; 
    } 
    

0 个答案:

没有答案