优化密码输入错误时登录日志重复问题
This commit is contained in:
parent
de37cf3e84
commit
ff304a1efb
@ -6,13 +6,9 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.ruoyi.common.constant.CacheConstants;
|
import com.ruoyi.common.constant.CacheConstants;
|
||||||
import com.ruoyi.common.constant.Constants;
|
|
||||||
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
||||||
import com.ruoyi.common.exception.user.UserPasswordRetryLimitExceedException;
|
import com.ruoyi.common.exception.user.UserPasswordRetryLimitExceedException;
|
||||||
import com.ruoyi.common.utils.MessageUtils;
|
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.framework.manager.AsyncManager;
|
|
||||||
import com.ruoyi.framework.manager.factory.AsyncFactory;
|
|
||||||
import com.ruoyi.framework.redis.RedisCache;
|
import com.ruoyi.framework.redis.RedisCache;
|
||||||
import com.ruoyi.framework.security.context.AuthenticationContextHolder;
|
import com.ruoyi.framework.security.context.AuthenticationContextHolder;
|
||||||
import com.ruoyi.project.system.domain.SysUser;
|
import com.ruoyi.project.system.domain.SysUser;
|
||||||
@ -60,16 +56,12 @@ public class SysPasswordService
|
|||||||
|
|
||||||
if (retryCount >= Integer.valueOf(maxRetryCount).intValue())
|
if (retryCount >= Integer.valueOf(maxRetryCount).intValue())
|
||||||
{
|
{
|
||||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL,
|
|
||||||
MessageUtils.message("user.password.retry.limit.exceed", maxRetryCount, lockTime)));
|
|
||||||
throw new UserPasswordRetryLimitExceedException(maxRetryCount, lockTime);
|
throw new UserPasswordRetryLimitExceedException(maxRetryCount, lockTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!matches(user, password))
|
if (!matches(user, password))
|
||||||
{
|
{
|
||||||
retryCount = retryCount + 1;
|
retryCount = retryCount + 1;
|
||||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL,
|
|
||||||
MessageUtils.message("user.password.retry.limit.count", retryCount)));
|
|
||||||
redisCache.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES);
|
redisCache.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES);
|
||||||
throw new UserPasswordNotMatchException();
|
throw new UserPasswordNotMatchException();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user