浏览代码

登录试错问题

xiaochan 1 年之前
父节点
当前提交
df57dafefe

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>12.1.0</version>
+    <version>12.1.1</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
     <properties>

+ 0 - 8
src/main/java/thyyxxk/webserver/dao/his/LoginDao.java

@@ -82,14 +82,6 @@ public interface LoginDao {
             "</script>")
     List<String> selectVueMenusPathByRoles(@Param("roles") List<Integer> roles);
 
-    @Select("select password " +
-            "from dj_user_base a, " +
-            "     a_employee_mi b " +
-            "where a.code = b.code " +
-            "  and isnull(nullif(b.del_flag, ''), 0) = 0 " +
-            "  and b.code = #{code}")
-    String getPasswordByCode(String code);
-
     @Select("select top 1 a.code, a.code_rs," +
             "             b.password " +
             "from a_employee_mi a, " +

+ 17 - 6
src/main/java/thyyxxk/webserver/service/LoginService.java

@@ -1,6 +1,5 @@
 package thyyxxk.webserver.service;
 
-import cn.hutool.core.date.DateTime;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.crypto.SecureUtil;
 import com.alibaba.fastjson.JSONObject;
@@ -66,13 +65,26 @@ public class LoginService {
             userInfo.setNextInputTimes(null);
             userInfo.setInputErrFrequency(times);
             // 输入次数大于三次锁定
-            if (times >= 3) {
-                now = DateUtil.offsetMinute(now, 10);
+            if (times > 3) {
+                // 如果当前时间在限制时间之前就用限制时间
+                if (now.toInstant().isBefore(tempUserInfo.getNextInputTimes().toInstant())) {
+                    now = tempUserInfo.getNextInputTimes();
+                } else {
+                    // 如果不在就加 10 分钟
+                    now = DateUtil.offsetMinute(now, 10);
+                }
                 userInfo.setNextInputTimes(now);
                 dao.addInputErrFrequency(tempUserInfo.getCodeRs(), times, now);
-                return ResultVoUtil.fail(ExceptionEnum.LOCK_OUT_THE_USER, StrUtil.format("用户已被锁定请:【{}】后重试。", DateUtil.formatDatetime(userInfo.getNextInputTimes())), userInfo);
             }
-            return ResultVoUtil.fail(ExceptionEnum.INVALID_PASSWORD, userInfo);
+            dao.addInputErrFrequency(tempUserInfo.getCodeRs(), times, now);
+            if (userInfo.getNextInputTimes() != null) {
+                return ResultVoUtil.fail(ExceptionEnum.LOCK_OUT_THE_USER,
+                        StrUtil.format("用户已被锁定请:【{}】后重试。",
+                                DateUtil.formatDatetime(userInfo.getNextInputTimes())),
+                        userInfo);
+            } else {
+                return ResultVoUtil.fail(ExceptionEnum.INVALID_PASSWORD, userInfo);
+            }
         }
 
         if (tempUserInfo.getInputErrFrequency() > 0) {
@@ -162,5 +174,4 @@ public class LoginService {
         return code + flakeIdSub + tokenSub;
     }
 
-
 }

+ 1 - 0
src/main/java/thyyxxk/webserver/utils/DateUtil.java

@@ -500,5 +500,6 @@ public class DateUtil extends cn.hutool.core.date.DateUtil {
         }
         return ageDays + "天";
     }
+
 }