@ -80,6 +80,8 @@ public class BladeUserDetails extends User {
*/
private final Kv detail;
public BladeUserDetails(Long userId, String tenantId, String oauthId, String name, String realName, String deptId, String postId, String roleId, String roleName, String avatar, String username, String password, Kv detail, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
this.userId = userId;
@ -43,6 +43,7 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.time.Duration;
import java.util.Date;
import java.util.List;
/**
@ -147,6 +148,12 @@ public class BladeUserDetailsServiceImpl implements UserDetailsService {
}
user.setRoleId(headerRole);
// 判断账号的停用时间
if(Func.isNotEmpty(user.getDownTime()) && user.getDownTime().getTime() < new Date().getTime()){
throw new UserDeniedAuthorizationException(TokenUtil.ACCOUNT_DISABLE);
// 成功则清除登录错误次数
delFailCount(tenantId, username);
return new BladeUserDetails(user.getId(),
@ -79,6 +79,7 @@ public class TokenUtil {
public final static String PASSWORD_KEY = "password";
public final static String GRANT_TYPE_KEY = "grant_type";
public final static String REFRESH_TOKEN_KEY = "refresh_token";
public final static String ACCOUNT_DISABLE = "当前账号已被禁用,请联系管理员";
private static BladeTenantProperties tenantProperties;
@ -92,5 +92,10 @@ public class User extends TenantEntity {
private String postId;
* 账号停用时间
private Date downTime;
@ -25,6 +25,7 @@
<result column="role_id" property="roleId"/>
<result column="dept_id" property="deptId"/>
<result column="post_id" property="postId"/>
<result column="down_time" property="downTime"/>
</resultMap>
<select id="selectUserPage" resultMap="userResultMap">