wangwei пре 7 година
родитељ
комит
f0cd518453

+ 7 - 4
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamController.java

@@ -457,7 +457,9 @@ public class ExamController extends ControllerSupport {
 			realIp = request.getHeader("x-real-ip");
 		}
 		if (StringUtils.isBlank(realIp)) {
-			throw new StatusException("E-001010", "网络受限");
+			map.put("limited", true);
+			map.put("desc", "网络受限");
+			return map;
 		}
 		realIp = realIp.trim();
 
@@ -469,9 +471,10 @@ public class ExamController extends ControllerSupport {
 
 			for (String cur : arr) {
 				String ip = StringUtils.replace(cur.trim(), ".", "\\.");
-				ip = StringUtils.replace(cur, "*", "\\w+");
+				ip = StringUtils.replace(ip, "*", "\\w+");
 				if (realIp.matches(ip)) {
 					limited = false;
+					map.put("desc", "IP段配置放行");
 					break;
 				}
 			}
@@ -495,10 +498,10 @@ public class ExamController extends ControllerSupport {
 						String clientIp = curUser.getClientIp();
 						if (null != clientIp) {
 							// IP取前三段
-							clientIp = clientIp.substring(0, clientIp.lastIndexOf("."));
+							clientIp = clientIp.substring(0, clientIp.lastIndexOf(".") + 1);
 							if (realIp.startsWith(clientIp)) {
 								limited = false;
-								map.put("desc", "机构管理员登录. key=" + userKey);
+								map.put("desc", "机构管理员[key=" + userKey + "]登录放行");
 								break;
 							}
 						}