过期用户也可以登录系统

This commit is contained in:
liuchengqian 2023-03-27 17:26:32 +08:00
parent ec1989cb80
commit 633e9d1c45

View File

@ -5,7 +5,6 @@ import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.service.SysAuthorityService;
import com.xkrs.service.SysRoleService;
import com.xkrs.service.SysUserService;
import com.xkrs.utilsnew.VipTimeRangeUtils;
import com.xkrs.utilsold.DateTimeUtil;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
@ -71,20 +70,20 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
// 检查用户是否存在
if (userEntity == null) {
throw new DisabledException("您的账号不存在,请您前往注册。");
throw new BadCredentialsException("您的账号不存在,请您前往注册。");
}
// 检查用户是否激活
if (userEntity.getActiveFlag() != 0) {
throw new DisabledException("您的账号未激活,详情请联系客服人员。");
}
// 检查用户是否在VIP时间范围内
boolean inVipTimeRange = VipTimeRangeUtils.checkIfInVipTimeRange(userEntity.getVipTimeRangeJson());
// 检查用户是否在试用期范围内
boolean inTryTimeRange = VipTimeRangeUtils.checkIfInTryTimeRange(userEntity.getAddTime(), userEntity.getDayNum());
//既不在VIP时间范围内 也不在试用期范围内
if ((!inVipTimeRange) && (!inTryTimeRange)) {
throw new DisabledException("您的账号已到期,详情请联系客服人员。");
}
// // 检查用户是否在VIP时间范围内
// boolean inVipTimeRange = VipTimeRangeUtils.checkIfInVipTimeRange(userEntity.getVipTimeRangeJson());
// // 检查用户是否在试用期范围内
// boolean inTryTimeRange = VipTimeRangeUtils.checkIfInTryTimeRange(userEntity.getAddTime(), userEntity.getDayNum());
// //既不在VIP时间范围内 也不在试用期范围内
// if ((!inVipTimeRange) && (!inTryTimeRange)) {
// throw new DisabledException("您的账号已到期,详情请联系客服人员。");
// }
// 认证逻辑
String encryptPassword = encry256(password + userEntity.getSalt());