Pu Zhibing
2024-10-16 c4664502dfdaffff555b532e65b51a57ac8b29c2
ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysPasswordService.java
@@ -10,6 +10,8 @@
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import javax.servlet.http.HttpServletRequest;
/**
 * 登录密码方法
 * 
@@ -39,7 +41,7 @@
        return CacheConstants.PWD_ERR_CNT_KEY + username;
    }
    public void validate(SysUser user, String password)
    public void validate(SysUser user, String password, HttpServletRequest request)
    {
        String username = user.getUserName();
@@ -53,14 +55,14 @@
        if (retryCount >= Integer.valueOf(maxRetryCount).intValue())
        {
            String errMsg = String.format("密码输入错误%s次,帐户锁定%s分钟", maxRetryCount, lockTime);
            recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL,errMsg);
            recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS,errMsg);
            throw new ServiceException(errMsg);
        }
        if (!matches(user, password))
        {
            retryCount = retryCount + 1;
            recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, String.format("密码输入错误%s次", retryCount));
            recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, String.format("密码输入错误%s次", retryCount));
            redisService.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES);
            throw new ServiceException("密码错误");
        }