增加quick登录验证

main
DESKTOP-C3M45P4\dengdan 2024-11-28 18:32:48 +08:00
parent 240ac95690
commit b949d0516e
2 changed files with 50 additions and 7 deletions

View File

@ -74,12 +74,24 @@ public class LoginSDKController extends HttpServlet {
DBObject dbObject = new BasicDBObject(); DBObject dbObject = new BasicDBObject();
dbObject.put("_id", openId); dbObject.put("_id", openId);
List<DBObject> userInfos = BaseGlobal.mongoDBPool.find(MongoKey.USER_INFO, dbObject); List<DBObject> userInfos = BaseGlobal.mongoDBPool.find(MongoKey.USER_INFO, dbObject);
if (!KSManager.ygLoginVerify(openId, sessionId)) { //quick验证
resp.put("result", 1); if(channel != null && channel.startsWith("Quick")){
resp.put("error", "verify error !!"); if(!KSManager.quickLoginVerify(openId, sessionId)){
out.print(resp); resp.put("result", 1);
out.flush(); resp.put("error", "verify error !!");
return; out.print(resp);
out.flush();
return;
}
}else{
//悠谷验证
if (!KSManager.ygLoginVerify(openId, sessionId)) {
resp.put("result", 1);
resp.put("error", "verify error !!");
out.print(resp);
out.flush();
return;
}
} }
if (userInfos.size() == 0) { if (userInfos.size() == 0) {
BaseGlobal.mongoDBPool.save(MongoKey.USER_INFO, dbObject); BaseGlobal.mongoDBPool.save(MongoKey.USER_INFO, dbObject);

View File

@ -1,12 +1,12 @@
package com.ljsd.sdk; package com.ljsd.sdk;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ljsd.controller.LoginSDKController;
import com.ljsd.util.BaseGlobal; import com.ljsd.util.BaseGlobal;
import com.ljsd.util.HttpClient; import com.ljsd.util.HttpClient;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -41,6 +41,9 @@ public class KSManager {
public static String OPEN_SERVER_STRATEGY = "1"; // 开服策略1 按注册量开 2 按时间开 public static String OPEN_SERVER_STRATEGY = "1"; // 开服策略1 按注册量开 2 按时间开
private static String QUICK_LOGIN_VERIFY_URL = "http://checkuser.quickapi.net/v2/checkUserInfo";
public final static String product_code = "32693415682925981428590879878901 ";
/** /**
@ -136,4 +139,32 @@ public class KSManager {
LOGGER.info("x7LoginVerify=====result={} json={}", result, json); LOGGER.info("x7LoginVerify=====result={} json={}", result, json);
return json; return json;
} }
public static boolean quickLoginVerify(String gameId, String token) {
boolean isOnline = Boolean.parseBoolean(BaseGlobal.properties.getProperty("isOnline"));
if (!isOnline){
return true;
}
Map<String, String> param = new HashMap<>(2);
param.put("uid", gameId);
param.put("token", token);
LOGGER.info("quick 登录验证-->{}",gameId);
Map<String,String> parms = new HashMap<>();
parms.put("token",token);
parms.put("product_code", product_code);
parms.put("uid",gameId);
String paramStr = HttpClient.joinParam(param);
boolean result = false;
try {
String r = HttpClient.sendGet(QUICK_LOGIN_VERIFY_URL, paramStr);
LOGGER.info("quick 请求结果:{}",r);
if (r != null && r.equals("1")) {
result = true;
}
}catch (Exception e){
LOGGER.info("quick 验证失败,IOException:{}",e.getMessage());
return false;
}
return result;
}
} }