我已经继承了 org.springframework.security.core.userdetails.User 并在我的构造函数中调用:
Super (String username,
String password,
boolean enabled,
boolean accountNonExpired,
boolean credentialsNonExpired,
boolean accountNonLocked,
GrantedAuthority[] authorities)
${SPRING_SECURITY_LAST_EXCEPTION.message}
然后我在登录失败时使用显示结果。
我遇到的问题是,如果我将 accountNotLocked 设置为 false,则会显示帐户锁定错误消息,无论密码是否正确都会发生这种情况。如果 spring 先验证凭据然后启用 accountNonExpired、credentialsNonExpired 和 accountNonLocked 标志,我会更喜欢它。这样,只有在他们获得正确的凭据时,才会通知用户他们的帐户已被锁定。
有没有办法强制弹簧这样做?