Fix crash when login

* Prevent email to be `null` to avoid crash in certain client setup.
This commit is contained in:
mingjun97 2022-04-30 21:16:50 -07:00 committed by Melledy
parent dd0f8f8d49
commit 582d91227c

View File

@ -381,6 +381,9 @@ public final class DispatchServer {
responseData.data.account.uid = requestData.uid; responseData.data.account.uid = requestData.uid;
responseData.data.account.token = requestData.token; responseData.data.account.token = requestData.token;
responseData.data.account.email = account.getEmail(); responseData.data.account.email = account.getEmail();
if (responseData.data.account.email == null) { // null will trigger crash in some client
responseData.data.account.email = "";
}
Grasscutter.getLogger().info(String.format("[Dispatch] Client %s logged in via token as %s", Grasscutter.getLogger().info(String.format("[Dispatch] Client %s logged in via token as %s",
req.ip(), responseData.data.account.uid)); req.ip(), responseData.data.account.uid));
@ -437,7 +440,7 @@ public final class DispatchServer {
// hk4e-sdk-os.hoyoverse.com // hk4e-sdk-os.hoyoverse.com
httpServer.get("/hk4e_global/mdk/agreement/api/getAgreementInfos", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"marketing_agreements\":[]}}")); httpServer.get("/hk4e_global/mdk/agreement/api/getAgreementInfos", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"marketing_agreements\":[]}}"));
// hk4e-sdk-os.hoyoverse.com // hk4e-sdk-os.hoyoverse.com
httpServer.post("/hk4e_global/combo/granter/api/compareProtocolVersion", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"modified\":true,\"protocol\":{\"id\":0,\"app_id\":4,\"language\":\"en\",\"user_proto\":\"\",\"priv_proto\":\"\",\"major\":7,\"minimum\":0,\"create_time\":\"0\",\"teenager_proto\":\"\",\"third_proto\":\"\"}}}")); httpServer.get("/hk4e_global/combo/granter/api/compareProtocolVersion", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"modified\":true,\"protocol\":{\"id\":0,\"app_id\":4,\"language\":\"en\",\"user_proto\":\"\",\"priv_proto\":\"\",\"major\":7,\"minimum\":0,\"create_time\":\"0\",\"teenager_proto\":\"\",\"third_proto\":\"\"}}}"));
// Game data // Game data
// hk4e-api-os.hoyoverse.com // hk4e-api-os.hoyoverse.com
@ -469,7 +472,7 @@ public final class DispatchServer {
// log-upload-os.mihoyo.com // log-upload-os.mihoyo.com
httpServer.all("/log/sdk/upload", new DispatchHttpJsonHandler("{\"code\":0}")); httpServer.all("/log/sdk/upload", new DispatchHttpJsonHandler("{\"code\":0}"));
httpServer.all("/sdk/upload", new DispatchHttpJsonHandler("{\"code\":0}")); httpServer.all("/sdk/upload", new DispatchHttpJsonHandler("{\"code\":0}"));
httpServer.post("/sdk/dataUpload", new DispatchHttpJsonHandler("{\"code\":0}")); httpServer.post("/sdk/dataUpload", (req, res) -> res.send("Hello"));
// /perf/config/verify?device_id=xxx&platform=x&name=xxx // /perf/config/verify?device_id=xxx&platform=x&name=xxx
httpServer.all("/perf/config/verify", new DispatchHttpJsonHandler("{\"code\":0}")); httpServer.all("/perf/config/verify", new DispatchHttpJsonHandler("{\"code\":0}"));
@ -479,6 +482,9 @@ public final class DispatchServer {
// log-upload-os.mihoyo.com // log-upload-os.mihoyo.com
httpServer.all("/crash/dataUpload", new ClientLogHandler()); httpServer.all("/crash/dataUpload", new ClientLogHandler());
// webstatic-sea.hoyoverse.com
httpServer.get("/admin/mi18n/plat_oversea/m202003048/m202003048-version.json", new DispatchHttpJsonHandler("{\"version\":51}"));
httpServer.get("/gacha", (req, res) -> res.send("<!doctype html><html lang=\"en\"><head><title>Gacha</title></head><body></body></html>")); httpServer.get("/gacha", (req, res) -> res.send("<!doctype html><html lang=\"en\"><head><title>Gacha</title></head><body></body></html>"));
httpServer.listen(Grasscutter.getConfig().getDispatchOptions().Port); httpServer.listen(Grasscutter.getConfig().getDispatchOptions().Port);