Răsfoiți Sursa

修改代码

wrh 2 ani în urmă
părinte
comite
fef9848268

+ 9 - 6
nngkxxdp/src/main/java/com/example/nngkxxdp/service/impl/ProblemUserServiceImpl.java

@@ -38,13 +38,16 @@ public class ProblemUserServiceImpl implements ProblemUserService {
             return SendUtil.send(false, ConstStr.USERNAME_ERROR);
         }
         String md5 = SecureUtil.md5(password);
-        Integer o = (Integer) redisUtil.get("Number of password errors:" + username);
-        if (!md5.equals(problemUser.getPassword()) || o >= ConstStr.LOGIN_ERROR_COUNT - 1) {
-            Integer count = 1;
-            if (Blank.isNotEmpty(o)) {
-                count = ++o;
-            }
+        Integer count = (Integer) redisUtil.get("Number of password errors:" + username);
+        if (Blank.isEmpty(count)) {
+            count = 0;
+        }
+        if (!md5.equals(problemUser.getPassword()) || count >= ConstStr.LOGIN_ERROR_COUNT) {
+            count++;
             if (count >= ConstStr.LOGIN_ERROR_COUNT) {
+                if (count.equals(ConstStr.LOGIN_ERROR_COUNT)) {
+                    redisUtil.set("Number of password errors:" + username, count, ConstStr.LOGIN_ERROR_LOCKING);
+                }
                 long expire = redisUtil.getExpire("Number of password errors:" + username);
                 long minutes = expire / 60;
                 long second = expire % 60;