Commit 392d800b authored by 廖旭伟's avatar 廖旭伟

登录错误5次账号锁定

parent 824c3d52
......@@ -32,6 +32,7 @@ import com.mortals.xhx.module.user.service.UserService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -61,6 +62,10 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Autowired
private UserPwdRecordDao userPwdRecordDao;
// 当日密码错误次数(默认60分钟)
@Value("${login.errorCount:5}")
private int ErrorCount;
/**
* @param data
* @return
......@@ -208,14 +213,16 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
if (sysUser.getLoginLock() == null) {
sysUser.setLoginLock(0);
}
//取消账户锁定功能
/* if (sysUser.getLoginLock() == 1 && sysUser.getLockTime() != null) {
//账户锁定功能
if (sysUser.getLoginLock() == 1 && sysUser.getLockTime() != null) {
String nowStr = DateUtils.getCurrStrDate();
String loginDateStr = DateUtils.getDateTime(sysUser.getLockTime(), "yyyy-MM-dd");
if (nowStr.equals(loginDateStr)) {
throw new AppException("此账号当天密码错误次数已达上限,已被锁定");
throw new AppException("此账号当天密码错误次数已达上限"+ErrorCount+"次,已被锁定");
}else {
sysUser.setLoginLock(0);
}
}*/
}
try {
if (StringUtils.isNotEmpty(sysUser.getSaltKey())) {
......@@ -225,7 +232,7 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
UserEntity update = new UserEntity();
update.setId(sysUser.getId());
update.setErrorCount(sysUser.getErrorCount() + 1);
if (update.getErrorCount() == 5) {
if (update.getErrorCount() == ErrorCount) {
update.setLoginLock(1);
update.setLockTime(new Date());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment