Эх сурвалжийг харах

Merge branch 'phone_verify' into dev

chenbiao 2 жил өмнө
parent
commit
349e491a09

+ 14 - 13
netflix-service/src/main/java/com/cyksj/service/user/impl/BadIntentionOpServiceImpl.java

@@ -37,6 +37,19 @@ public class BadIntentionOpServiceImpl implements BadIntentionOpService {
         if ("13662979985".equals(phone)) {
             throw BusinessRuntimeException.getInstance("异常手机号");
         }
+        if (StringUtils.isBlank(verifyCode)) {
+            throw BusinessRuntimeException.getInstance("人机校验不通过");
+        }else {
+            JSONObject parmas = new JSONObject();
+            parmas.putOpt("api_key", apiKey);
+            parmas.putOpt("response", verifyCode);
+            String post = HttpUtil.post(VERIFY_URL, parmas.toString());
+            JSONObject res = new JSONObject(post);
+            if (!res.getStr("res").equals("success")) {
+                log.error("手机号:{}验证码校验不通过 res:{}", phone, res);
+                throw BusinessRuntimeException.getInstance("人机校验不通过");
+            }
+        }
         String dayKey = RedisService.key.PHONE_CODE_USER_NUM_KEY_DAY.getName() + phone;
         if (redisService.hasKey(RedisService.key.PHONE_CODE_BALCK_KEY.getName() + phone)) {
             throw BusinessRuntimeException.getInstance("异常手机号");
@@ -52,19 +65,6 @@ public class BadIntentionOpServiceImpl implements BadIntentionOpService {
                 log.error("手机号:{}频繁获取短信验证码", phone);
                 throw BusinessRuntimeException.getInstance("请勿频繁获取短信验证码");
             }
-            if (StringUtils.isBlank(verifyCode)) {
-                throw BusinessRuntimeException.getInstance("人机校验不通过");
-            }else {
-                JSONObject parmas = new JSONObject();
-                parmas.putOpt("api_key", apiKey);
-                parmas.putOpt("response", verifyCode);
-                String post = HttpUtil.post(VERIFY_URL, parmas.toString());
-                JSONObject res = new JSONObject(post);
-                if (!res.getStr("res").equals("success")) {
-                    log.error("手机号:{}验证码校验不通过 res:{}", phone, res);
-                    throw BusinessRuntimeException.getInstance("人机校验不通过");
-                }
-            }
             return;
         }
         redisService.set(dayKey, 1, RedisService.key.PHONE_CODE_USER_NUM_KEY_DAY.getTimeout());
@@ -74,6 +74,7 @@ public class BadIntentionOpServiceImpl implements BadIntentionOpService {
     @Override
     public void isBadOpLoginPhone(HttpServletRequest request, String phone) {
         String ip = StringUtil.getInternalAddressByIP(ServletUtil.getClientIP(request));
+        log.info("--------------校验ip 是否黑名单------- ip:{}", ip);
         String blackIpKey = RedisService.key.BALCK_USER_IP_KEY + ip;
         if (redisService.hasKey(blackIpKey)) {
             throw BusinessRuntimeException.getInstance("检测到您操作异常,请联系客服");