From 66a2bbaed29c6134b84e0916c96916a983bc64e8 Mon Sep 17 00:00:00 2001 From: zjh <1084500556@qq.com> Date: 星期五, 20 十月 2023 11:02:58 +0800 Subject: [PATCH] zjh 2023/10/20--1 --- ltkj-framework/src/main/java/com/ltkj/framework/web/service/SysLoginService.java | 34 ++++++++++++++++++---------------- 1 files changed, 18 insertions(+), 16 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..910b304 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(); + } } // 鐢ㄦ埛楠岃瘉 -- Gitblit v1.8.0