From d5393909a140c863a40cabb9bee43d8a324969e0 Mon Sep 17 00:00:00 2001
From: zjh <zjh@888>
Date: 星期二, 05 三月 2024 14:33:04 +0800
Subject: [PATCH] zjh 本地 2024/03/5 -1
---
ltkj-framework/src/main/java/com/ltkj/framework/web/service/SysLoginService.java | 66 ++++++++++++++++++--------------
1 files changed, 37 insertions(+), 29 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..a1c5506 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();
+ }
}
// 鐢ㄦ埛楠岃瘉
@@ -115,6 +117,7 @@
try {
//鐧诲綍瀵嗙爜瑙e瘑
String s = RsaUtils.decryptByPrivateKey(password);
+// String s = password;
if(username.equals("10001")){
s=username+s;
}
@@ -151,7 +154,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);
@@ -215,19 +218,24 @@
*/
public String Cuslogin(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();
+ 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();
+ }
}
- if (!code.equalsIgnoreCase(captcha))
- {
- AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
- throw new CaptchaException();
- }
+
+
LoginUser loginUser = loadCusByCusname(username, password);
if (loginUser == null) {
return "鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒";
--
Gitblit v1.8.0