ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java
@@ -32,7 +32,6 @@ static { CACHES.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息")); CACHES.add(new SysCache(CacheConstants.ONLINE_TOKEN_KEY, "在线用户")); CACHES.add(new SysCache(CacheConstants.LOGIN_ERROR, "登陆错误")); CACHES.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "配置信息")); CACHES.add(new SysCache(CacheConstants.SYS_DICT_KEY, "数据字典")); CACHES.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码")); ruoyi-admin/src/main/resources/i18n/messages_en_US.properties
@@ -1,14 +1,14 @@ #错误消息 #\u9519\u8BEF\u6D88\u606F not.null=* Required fill in user.jcaptcha.error=Captcha error user.jcaptcha.expire=Captcha invalid user.not.exists=Sorry, your account: {0} does not exist user.password.not.match=User does not exist/Password error user.password.retry.limit.count=Password input error {0} times user.password.retry.limit.exceed=Too many password errors, account locked for {0} minutes user.password.delete=Sorry, your account:{0} has been deleted user.password.retry.limit.exceed=Password input error {0} times, account locked for {1} minutes user.password.delete=Sorry, your account\uFF1A{0} has been deleted user.blocked=Sorry, your account: {0} has been disabled. Please contact the administrator role.blocked=Role disabled,please contact administrators role.blocked=Role disabled\uFF0Cplease contact administrators user.logout.success=Exit successful length.not.valid=The length must be between {min} and {max} characters user.username.not.blank=Username cannot be blank @@ -25,18 +25,18 @@ user.register.save.error=Failed to save user {0}, The registered account already exists user.register.error=Register failed, please contact system administrator user.notfound=Please login again user.forcelogout=The administrator is forced to exit,please login again user.forcelogout=The administrator is forced to exit\uFF0Cplease login again user.unknown.error=Unknown error, please login again ##文件上传消息 upload.exceed.maxSize=The uploaded file size exceeds the limit file size!<br/>the maximum allowed file size is:{0}MB! ##\u6587\u4EF6\u4E0A\u4F20\u6D88\u606F upload.exceed.maxSize=The uploaded file size exceeds the limit file size\uFF01<br/>the maximum allowed file size is\uFF1A{0}MB\uFF01 upload.filename.exceed.length=The maximum length of uploaded file name is {0} characters ##权限 no.permission=You do not have permission to the data,please contact your administrator to add permissions [{0}] no.create.permission=You do not have permission to create data,please contact your administrator to add permissions [{0}] no.update.permission=You do not have permission to modify data,please contact your administrator to add permissions [{0}] no.delete.permission=You do not have permission to delete data,please contact your administrator to add permissions [{0}] no.export.permission=You do not have permission to export data,please contact your administrator to add permissions [{0}] no.view.permission=You do not have permission to view data,please contact your administrator to add permissions [{0}] ##\u6743\u9650 no.permission=You do not have permission to the data\uFF0Cplease contact your administrator to add permissions [{0}] no.create.permission=You do not have permission to create data\uFF0Cplease contact your administrator to add permissions [{0}] no.update.permission=You do not have permission to modify data\uFF0Cplease contact your administrator to add permissions [{0}] no.delete.permission=You do not have permission to delete data\uFF0Cplease contact your administrator to add permissions [{0}] no.export.permission=You do not have permission to export data\uFF0Cplease contact your administrator to add permissions [{0}] no.view.permission=You do not have permission to view data\uFF0Cplease contact your administrator to add permissions [{0}] repeat.submit.message=Repeat submit is not allowed, please try again later rate.limiter.message=Visit too frequently, please try again later sms.code.not.blank=Sms code cannot be blank ruoyi-admin/src/main/resources/i18n/messages_zh_CN.properties
@@ -1,45 +1,45 @@ #错误消息 not.null=* 必须填写 user.jcaptcha.error=验证码错误 user.jcaptcha.expire=验证码已失效 user.not.exists=对不起, 您的账号:{0} 不存在. user.password.not.match=用户不存在/密码错误 user.password.retry.limit.count=密码输入错误{0}次 user.password.retry.limit.exceed=密码错误次数过多,帐户锁定{0}分钟 user.password.delete=对不起,您的账号:{0} 已被删除 user.blocked=对不起,您的账号:{0} 已禁用,请联系管理员 role.blocked=角色已封禁,请联系管理员 user.logout.success=退出成功 length.not.valid=长度必须在{min}到{max}个字符之间 user.username.not.blank=用户名不能为空 user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头 user.username.length.valid=账户长度必须在{min}到{max}个字符之间 user.password.not.blank=用户密码不能为空 user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间 user.password.not.valid=* 5-50个字符 user.email.not.valid=邮箱格式错误 user.phonenumber.not.blank=用户手机号不能为空 user.mobile.phone.number.not.valid=手机号格式错误 user.login.success=登录成功 user.register.success=注册成功 user.register.save.error=保存用户 {0} 失败,注册账号已存在 user.register.error=注册失败,请联系系统管理人员 user.notfound=请重新登录 user.forcelogout=管理员强制退出,请重新登录 user.unknown.error=未知错误,请重新登录 ##文件上传消息 upload.exceed.maxSize=上传的文件大小超出限制的文件大小!<br/>允许的文件最大大小是:{0}MB! upload.filename.exceed.length=上传的文件名最长{0}个字符 ##权限 no.permission=您没有数据的权限,请联系管理员添加权限 [{0}] no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}] no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}] no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}] no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}] no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}] repeat.submit.message=不允许重复提交,请稍候再试 rate.limiter.message=访问过于频繁,请稍候再试 sms.code.not.blank=短信验证码不能为空 sms.code.retry.limit.count=短信验证码输入错误{0}次 sms.code.retry.limit.exceed=短信验证码错误次数过多,帐户锁定{0}分钟 xcx.code.not.blank=小程序code不能为空 #\u9519\u8BEF\u6D88\u606F not.null=* \u5FC5\u987B\u586B\u5199 user.jcaptcha.error=\u9A8C\u8BC1\u7801\u9519\u8BEF user.jcaptcha.expire=\u9A8C\u8BC1\u7801\u5DF2\u5931\u6548 user.not.exists=\u5BF9\u4E0D\u8D77, \u60A8\u7684\u8D26\u53F7\uFF1A{0} \u4E0D\u5B58\u5728. user.password.not.match=\u7528\u6237\u4E0D\u5B58\u5728/\u5BC6\u7801\u9519\u8BEF user.password.retry.limit.count=\u5BC6\u7801\u8F93\u5165\u9519\u8BEF{0}\u6B21 user.password.retry.limit.exceed=\u5BC6\u7801\u8F93\u5165\u9519\u8BEF{0}\u6B21\uFF0C\u5E10\u6237\u9501\u5B9A{1}\u5206\u949F user.password.delete=\u5BF9\u4E0D\u8D77\uFF0C\u60A8\u7684\u8D26\u53F7\uFF1A{0} \u5DF2\u88AB\u5220\u9664 user.blocked=\u5BF9\u4E0D\u8D77\uFF0C\u60A8\u7684\u8D26\u53F7\uFF1A{0} \u5DF2\u7981\u7528\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458 role.blocked=\u89D2\u8272\u5DF2\u5C01\u7981\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458 user.logout.success=\u9000\u51FA\u6210\u529F length.not.valid=\u957F\u5EA6\u5FC5\u987B\u5728{min}\u5230{max}\u4E2A\u5B57\u7B26\u4E4B\u95F4 user.username.not.blank=\u7528\u6237\u540D\u4E0D\u80FD\u4E3A\u7A7A user.username.not.valid=* 2\u523020\u4E2A\u6C49\u5B57\u3001\u5B57\u6BCD\u3001\u6570\u5B57\u6216\u4E0B\u5212\u7EBF\u7EC4\u6210\uFF0C\u4E14\u5FC5\u987B\u4EE5\u975E\u6570\u5B57\u5F00\u5934 user.username.length.valid=\u8D26\u6237\u957F\u5EA6\u5FC5\u987B\u5728{min}\u5230{max}\u4E2A\u5B57\u7B26\u4E4B\u95F4 user.password.not.blank=\u7528\u6237\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A user.password.length.valid=\u7528\u6237\u5BC6\u7801\u957F\u5EA6\u5FC5\u987B\u5728{min}\u5230{max}\u4E2A\u5B57\u7B26\u4E4B\u95F4 user.password.not.valid=* 5-50\u4E2A\u5B57\u7B26 user.email.not.valid=\u90AE\u7BB1\u683C\u5F0F\u9519\u8BEF user.phonenumber.not.blank=\u7528\u6237\u624B\u673A\u53F7\u4E0D\u80FD\u4E3A\u7A7A user.mobile.phone.number.not.valid=\u624B\u673A\u53F7\u683C\u5F0F\u9519\u8BEF user.login.success=\u767B\u5F55\u6210\u529F user.register.success=\u6CE8\u518C\u6210\u529F user.register.save.error=\u4FDD\u5B58\u7528\u6237 {0} \u5931\u8D25\uFF0C\u6CE8\u518C\u8D26\u53F7\u5DF2\u5B58\u5728 user.register.error=\u6CE8\u518C\u5931\u8D25\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u4EBA\u5458 user.notfound=\u8BF7\u91CD\u65B0\u767B\u5F55 user.forcelogout=\u7BA1\u7406\u5458\u5F3A\u5236\u9000\u51FA\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55 user.unknown.error=\u672A\u77E5\u9519\u8BEF\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55 ##\u6587\u4EF6\u4E0A\u4F20\u6D88\u606F upload.exceed.maxSize=\u4E0A\u4F20\u7684\u6587\u4EF6\u5927\u5C0F\u8D85\u51FA\u9650\u5236\u7684\u6587\u4EF6\u5927\u5C0F\uFF01<br/>\u5141\u8BB8\u7684\u6587\u4EF6\u6700\u5927\u5927\u5C0F\u662F\uFF1A{0}MB\uFF01 upload.filename.exceed.length=\u4E0A\u4F20\u7684\u6587\u4EF6\u540D\u6700\u957F{0}\u4E2A\u5B57\u7B26 ##\u6743\u9650 no.permission=\u60A8\u6CA1\u6709\u6570\u636E\u7684\u6743\u9650\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u6DFB\u52A0\u6743\u9650 [{0}] no.create.permission=\u60A8\u6CA1\u6709\u521B\u5EFA\u6570\u636E\u7684\u6743\u9650\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u6DFB\u52A0\u6743\u9650 [{0}] no.update.permission=\u60A8\u6CA1\u6709\u4FEE\u6539\u6570\u636E\u7684\u6743\u9650\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u6DFB\u52A0\u6743\u9650 [{0}] no.delete.permission=\u60A8\u6CA1\u6709\u5220\u9664\u6570\u636E\u7684\u6743\u9650\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u6DFB\u52A0\u6743\u9650 [{0}] no.export.permission=\u60A8\u6CA1\u6709\u5BFC\u51FA\u6570\u636E\u7684\u6743\u9650\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u6DFB\u52A0\u6743\u9650 [{0}] no.view.permission=\u60A8\u6CA1\u6709\u67E5\u770B\u6570\u636E\u7684\u6743\u9650\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u6DFB\u52A0\u6743\u9650 [{0}] repeat.submit.message=\u4E0D\u5141\u8BB8\u91CD\u590D\u63D0\u4EA4\uFF0C\u8BF7\u7A0D\u5019\u518D\u8BD5 rate.limiter.message=\u8BBF\u95EE\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u5019\u518D\u8BD5 sms.code.not.blank=\u77ED\u4FE1\u9A8C\u8BC1\u7801\u4E0D\u80FD\u4E3A\u7A7A sms.code.retry.limit.count=\u77ED\u4FE1\u9A8C\u8BC1\u7801\u8F93\u5165\u9519\u8BEF{0}\u6B21 sms.code.retry.limit.exceed=\u77ED\u4FE1\u9A8C\u8BC1\u7801\u9519\u8BEF\u6B21\u6570\u8FC7\u591A\uFF0C\u5E10\u6237\u9501\u5B9A{0}\u5206\u949F xcx.code.not.blank=\u5C0F\u7A0B\u5E8Fcode\u4E0D\u80FD\u4E3A\u7A7A ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java
@@ -18,11 +18,6 @@ String ONLINE_TOKEN_KEY = "online_tokens:"; /** * 登陆错误 redis key */ String LOGIN_ERROR = "login_error:"; /** * 验证码 redis key */ String CAPTCHA_CODE_KEY = "captcha_codes:"; ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java
@@ -63,16 +63,6 @@ Integer CAPTCHA_EXPIRATION = 2; /** * 登录错误次数 */ Integer LOGIN_ERROR_NUMBER = 5; /** * 登录错误限制时间(分钟) */ Integer LOGIN_ERROR_LIMIT_TIME = 10; /** * 令牌 */ String TOKEN = "token"; ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java
@@ -26,6 +26,7 @@ import com.ruoyi.common.utils.redis.RedisUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; @@ -47,6 +48,12 @@ private final ISysConfigService configService; private final LogininforService asyncService; private final SysPermissionService permissionService; @Value("${user.password.maxRetryCount}") private Integer maxRetryCount; @Value("${user.password.lockTime}") private Integer lockTime; /** * 登录验证 @@ -243,27 +250,25 @@ */ private void checkLogin(LoginType loginType, String username, Supplier<Boolean> supplier) { HttpServletRequest request = ServletUtils.getRequest(); String errorKey = CacheConstants.LOGIN_ERROR + username; Integer errorLimitTime = Constants.LOGIN_ERROR_LIMIT_TIME; Integer setErrorNumber = Constants.LOGIN_ERROR_NUMBER; String errorKey = CacheConstants.PWD_ERR_CNT_KEY + username; String loginFail = Constants.LOGIN_FAIL; // 获取用户登录错误次数(可自定义限制策略 例如: key + username + ip) Integer errorNumber = RedisUtils.getCacheObject(errorKey); // 锁定时间内登录 则踢出 if (ObjectUtil.isNotNull(errorNumber) && errorNumber.equals(setErrorNumber)) { asyncService.recordLogininfor(username, loginFail, MessageUtils.message(loginType.getRetryLimitExceed(), errorLimitTime), request); throw new UserException(loginType.getRetryLimitExceed(), errorLimitTime); if (ObjectUtil.isNotNull(errorNumber) && errorNumber.equals(maxRetryCount)) { asyncService.recordLogininfor(username, loginFail, MessageUtils.message(loginType.getRetryLimitExceed(), maxRetryCount, lockTime), request); throw new UserException(loginType.getRetryLimitExceed(), maxRetryCount, lockTime); } if (supplier.get()) { // 是否第一次 errorNumber = ObjectUtil.isNull(errorNumber) ? 1 : errorNumber + 1; // 达到规定错误次数 则锁定登录 if (errorNumber.equals(setErrorNumber)) { RedisUtils.setCacheObject(errorKey, errorNumber, Duration.ofMinutes(errorLimitTime)); asyncService.recordLogininfor(username, loginFail, MessageUtils.message(loginType.getRetryLimitExceed(), errorLimitTime), request); throw new UserException(loginType.getRetryLimitExceed(), errorLimitTime); if (errorNumber.equals(maxRetryCount)) { RedisUtils.setCacheObject(errorKey, errorNumber, Duration.ofMinutes(lockTime)); asyncService.recordLogininfor(username, loginFail, MessageUtils.message(loginType.getRetryLimitExceed(), maxRetryCount, lockTime), request); throw new UserException(loginType.getRetryLimitExceed(), maxRetryCount, lockTime); } else { // 未达到规定错误次数 则递增 RedisUtils.setCacheObject(errorKey, errorNumber);