|
|
@@ -54,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
@@ -126,11 +127,30 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|
|
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.USER_DISABLED);
|
|
|
throw exception(AUTH_LOGIN_USER_DISABLED);
|
|
|
}
|
|
|
+ // 校验是否过期
|
|
|
+ if (isExpired(user.getExpireTime())) {
|
|
|
+ createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.USER_EXPIRED);
|
|
|
+ throw exception(AUTH_LOGIN_USER_EXPIRED);
|
|
|
+ }
|
|
|
// 新增登录校验规则
|
|
|
// addAuthenticate(user, username);
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
+ public boolean isExpired(LocalDateTime expireTime) {
|
|
|
+ // 1. 处理null场景:根据业务需求调整(比如null表示永不过期)
|
|
|
+ if (expireTime == null) {
|
|
|
+ return true; // 若null需视为过期,可改为return true
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 获取当前系统时间(默认使用系统默认时区)
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+
|
|
|
+ // 3. 核心对比:当前时间 > 过期时间 → 已过期
|
|
|
+ // isAfter():判断当前时间是否在过期时间之后
|
|
|
+ return now.isAfter(expireTime);
|
|
|
+ }
|
|
|
+
|
|
|
/*public void addAuthenticate(AdminUserDO user, String username) {
|
|
|
// 检查用户在该模块是否是黑名单
|
|
|
String headerModule = ServletUtils.getRequest().getHeader("Module");
|
|
|
@@ -414,6 +434,12 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|
|
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.USER_DISABLED);
|
|
|
throw exception(AUTH_LOGIN_USER_DISABLED);
|
|
|
}
|
|
|
+ // 校验是否过期
|
|
|
+ if (isExpired(user.getExpireTime())) {
|
|
|
+ createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.USER_EXPIRED);
|
|
|
+ throw exception(AUTH_LOGIN_USER_EXPIRED);
|
|
|
+ }
|
|
|
+
|
|
|
// 新增登录校验规则
|
|
|
// addAuthenticate(user, username);
|
|
|
return user;
|