From d692b45b22f985aff4635a5bb8b8958ae9bcd6dd Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 21 十月 2022 17:50:09 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/service/sys/UserService.java |   50 ++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/lf/server/service/sys/UserService.java b/src/main/java/com/lf/server/service/sys/UserService.java
index 8d49085..8e539b6 100644
--- a/src/main/java/com/lf/server/service/sys/UserService.java
+++ b/src/main/java/com/lf/server/service/sys/UserService.java
@@ -1,7 +1,5 @@
 package com.lf.server.service.sys;
 
-import com.lf.server.entity.all.RedisCacheKey;
-import com.lf.server.entity.all.SettingData;
 import com.lf.server.entity.sys.UserEntity;
 import com.lf.server.helper.Md5Helper;
 import com.lf.server.helper.RsaHelper;
@@ -9,11 +7,9 @@
 import com.lf.server.mapper.sys.UserMapper;
 import com.lf.server.service.all.RedisService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.cache.RedisCache;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
-import java.util.concurrent.TimeUnit;
 
 /**
  * 鐢ㄦ埛琛�
@@ -28,6 +24,12 @@
 
     @Autowired
     RedisService redisService;
+
+    @Autowired
+    LoginService loginService;
+
+    @Autowired
+    TokenService tokenService;
 
     @Override
     public Integer selectCount(String uname) {
@@ -125,6 +127,33 @@
     }
 
     /**
+     * 楠岃瘉鐧诲綍鐢ㄦ埛瀵嗙爜
+     */
+    public String validateLoginPwd(UserEntity entity) {
+        try {
+            String str = validateUserEntity(entity);
+            if (str != null) {
+                return str;
+            }
+
+            // 瑙e瘑
+            String uid = RsaHelper.decrypt(entity.getUid());
+            String pwd = RsaHelper.decrypt(entity.getPwd());
+
+            entity.setUid(uid);
+            entity.setPwd(pwd);
+
+            if (tokenService.isUidDisable(entity)) {
+                return "鐢ㄦ埛ID宸茬鐢�";
+            }
+
+            return null;
+        } catch (Exception ex) {
+            return "瑙e瘑澶辫触";
+        }
+    }
+
+    /**
      * 楠岃瘉鏂扮敤鎴峰瘑鐮�
      */
     public String validateNewPwd(UserEntity entity) {
@@ -147,7 +176,7 @@
 
             return null;
         } catch (Exception ex) {
-            return "瀵嗙爜瑙e瘑澶辫触";
+            return "瑙e瘑澶辫触";
         }
     }
 
@@ -173,8 +202,8 @@
                 return "娌℃湁鎵惧埌鐢ㄦ埛";
             }
             if (!Md5Helper.validatePassword(pwd, ue.getPwd())) {
-                //
-                return "鏃у瘑鐮佽緭鍏ラ敊璇�";
+                tokenService.setPwdErrCache(ue);
+                return "鏃у瘑鐮佷笉姝g‘";
             }
             if (!StringHelper.checkPwdValid(salt)) {
                 return "瀵嗙爜涓嶇鍚堣姹�";
@@ -187,7 +216,7 @@
 
             return null;
         } catch (Exception ex) {
-            return "瀵嗙爜瑙e瘑澶辫触";
+            return "瑙e瘑澶辫触";
         }
     }
 
@@ -205,12 +234,13 @@
         try {
             String pwd = RsaHelper.decrypt(adminPwd);
             if (!Md5Helper.validatePassword(pwd, ue.getPwd())) {
+                tokenService.setPwdErrCache(ue);
                 return "绠$悊鍛樺瘑鐮佷笉姝g‘";
             }
 
             return null;
         } catch (Exception ex) {
-            return "瀵嗙爜瑙e瘑澶辫触";
+            return "瑙e瘑澶辫触";
         }
     }
 
@@ -233,7 +263,7 @@
 
             return null;
         } catch (Exception ex) {
-            return "瀵嗙爜瑙e瘑澶辫触";
+            return "瑙e瘑澶辫触";
         }
     }
 }

--
Gitblit v1.9.3