From 4aa9b8cb058bcf4bae95d80810ce2ccde3406ee8 Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期一, 06 十一月 2023 11:59:41 +0800
Subject: [PATCH] zjh 2023/11/06--1

---
 ltkj-framework/src/main/java/com/ltkj/framework/web/service/SysLoginService.java |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/ltkj-framework/src/main/java/com/ltkj/framework/web/service/SysLoginService.java b/ltkj-framework/src/main/java/com/ltkj/framework/web/service/SysLoginService.java
index 45ab164..7722c26 100644
--- a/ltkj-framework/src/main/java/com/ltkj/framework/web/service/SysLoginService.java
+++ b/ltkj-framework/src/main/java/com/ltkj/framework/web/service/SysLoginService.java
@@ -19,9 +19,7 @@
 import com.ltkj.hosp.domain.TjCustomer;
 import com.ltkj.hosp.service.IDictHospService;
 import com.ltkj.hosp.service.ITjCustomerService;
-import com.ltkj.system.service.ISysDeptService;
-import com.ltkj.system.service.ISysMenuService;
-import com.ltkj.system.service.SysParametersDisposeService;
+import com.ltkj.system.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.authentication.AuthenticationManager;
@@ -39,7 +37,6 @@
 import com.ltkj.framework.manager.AsyncManager;
 import com.ltkj.framework.manager.factory.AsyncFactory;
 import com.ltkj.framework.security.context.AuthenticationContextHolder;
-import com.ltkj.system.service.ISysUserService;
 
 import java.util.Date;
 import java.util.HashMap;
@@ -75,6 +72,8 @@
     private ISysDeptService deptService;
     @Autowired
     private SysParametersDisposeService parametersDisposeService;
+    @Autowired
+    private ISysConfigService configService;
 
     // 鏄惁鍏佽璐︽埛澶氱粓绔悓鏃剁櫥褰曪紙true鍏佽 false涓嶅厑璁革級
     @Value("${token.soloLogin}")
@@ -96,18 +95,21 @@
      */
     public String login(String username, String password, Boolean type,String code,String uuid) {
 
-        String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
-        String captcha = redisCache.getCacheObject(verifyKey);
-        redisCache.deleteObject(verifyKey);
-        if (captcha == null)
-        {
-            AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
-            throw new CaptchaExpireException();
-        }
-        if (!code.equalsIgnoreCase(captcha))
-        {
-            AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
-            throw new CaptchaException();
+        String aSwitch = configService.selectConfigByKey("captcha_switch");
+        if(null !=aSwitch && aSwitch.equals("Y")){
+            String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
+            String captcha = redisCache.getCacheObject(verifyKey);
+            redisCache.deleteObject(verifyKey);
+            if (captcha == null)
+            {
+                AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
+                throw new CaptchaExpireException();
+            }
+            if (!code.equalsIgnoreCase(captcha))
+            {
+                AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
+                throw new CaptchaException();
+            }
         }
 
         // 鐢ㄦ埛楠岃瘉
@@ -151,7 +153,7 @@
                             if(!SecurityUtils.isAdmin(user.getUserId())){
                                 if(dictHosp.getSecretKey() != null && dictHosp.getExpirationTime() != null){
                                     if (!SecurityUtils.matchesMallMerchantSecretKey(secret,dictHosp.getHospAreaId(),dictHosp.getHospAreaName(),
-                                            dictHosp.getExpirationTime(),dictHosp.getSecretKey())) {
+                                            dictHosp.getExpirationTime(),dictHosp.getSecretKey()) || new Date().after(DateUtil.endOfDay(dictHosp.getExpirationTime()))) {
                                         throw new SecretKeyException("鍟嗗宸茶繃鏈熻缁垂浣跨敤");
                                     }
                                     long between = DateUtil.between(new Date(), DateUtil.endOfDay(dictHosp.getExpirationTime()), DateUnit.DAY);

--
Gitblit v1.8.0