andy 1 年之前
父节点
当前提交
ef31ed1e28

+ 2 - 2
src/main/java/com/scbfkj/uni/library/RequestUtil.java

@@ -75,9 +75,9 @@ public class RequestUtil {
         if (Objects.isNull(application)) {
             String appToken = getAppToken();
             String requestIp = getIpAddr();
-            String query = "select appid from appconnectlog where apptoken=? and requestip =?";
+            String query = "select appid from appconnectlog where apptoken=? and requestip =? and expiretime >  ?";
             List<Map<String, Object>> appConnectLogList = DataBase.query(Config.getSecurityConnectionStr(), query,
-                    appToken, requestIp);
+                    appToken, requestIp, LocalDateTime.now());
             if (appConnectLogList.isEmpty()) {
                 throw new RuntimeException("当前连接未登录");
             }

+ 3 - 3
src/main/java/com/scbfkj/uni/service/SecurityService.java

@@ -334,7 +334,7 @@ public class SecurityService {
                      where apptoken=? and sessionid=? and requestip=? and isexpires=0 """;
         List<Map<String, Object>> userLoginLogList = DataBase.query(Config.getSecurityConnectionStr(), query, appToken, sessionId, ip);
         if (userLoginLogList.isEmpty()) {
-            return UniReturnUtil.fail("登录失败");
+            return UniReturnUtil.fail("登录失败:在数据库中没有找到当前session的登录请求");
         }
         Map<String, Object> userLoginLog = userLoginLogList.get(0);
         Object securityCodeEffectiveObj = application.get("securitycodeeffective");
@@ -426,9 +426,9 @@ public class SecurityService {
         }
         Map<String, Object> userLoginLog = userLoginLogList.get(0);
         Object userIdObj = userLoginLog.get("userid");
-        String delete = "delete from userloginlog where  userid=?";
+        String delete = "update userloginlog set  isexpires=1, logouttime=? where userid=?  and  usertoken=? and sessionid=?";
         DataBase.update(Config.getSecurityConnectionStr(), delete,
-                userIdObj
+                LocalDateTime.now(), userIdObj, userToken, sessionId
         );
         return UniReturnUtil.success("成功");
     }