diff --git a/src/main/java/com/xtaolabs/gcauth_oauth/GCAuth_OAuth.java b/src/main/java/com/xtaolabs/gcauth_oauth/GCAuth_OAuth.java index b410d3d..3fe3362 100644 --- a/src/main/java/com/xtaolabs/gcauth_oauth/GCAuth_OAuth.java +++ b/src/main/java/com/xtaolabs/gcauth_oauth/GCAuth_OAuth.java @@ -2,9 +2,9 @@ package com.xtaolabs.gcauth_oauth; import emu.grasscutter.Grasscutter; import emu.grasscutter.plugin.Plugin; -import emu.grasscutter.server.dispatch.DispatchHttpJsonHandler; import static emu.grasscutter.Configuration.*; +import com.xtaolabs.gcauth_oauth.handler.JsonHandler; import com.xtaolabs.gcauth_oauth.handler.VerifyHandler; import com.xtaolabs.gcauth_oauth.handler.RequestHandler; @@ -39,12 +39,7 @@ public class GCAuth_OAuth extends Plugin { String folder_name = PLUGINS_FOLDER + "/GCAuth/OAuth/"; Express app = Grasscutter.getDispatchServer().getServer(); - app.get("/Api/twitter_login", new DispatchHttpJsonHandler( - String.format("{\"code\":200,\"data\":{\"auth_url\":\"%s\",\"info\":\"\",\"msg\":\"Success\",\"status\":1}}", - "http" + (DISPATCH_ENCRYPTION.useEncryption ? "s" : "") + "://" - + lr(DISPATCH_INFO.accessAddress, DISPATCH_INFO.bindAddress) + ":" - + lr(DISPATCH_INFO.accessPort, DISPATCH_INFO.bindPort) + "/gcauth_oauth/login.html") - )); + app.get("/Api/twitter_login", new JsonHandler()); app.post("/gcauth_oauth/login", new RequestHandler()); diff --git a/src/main/java/com/xtaolabs/gcauth_oauth/handler/JsonHandler.java b/src/main/java/com/xtaolabs/gcauth_oauth/handler/JsonHandler.java new file mode 100644 index 0000000..8d8d8e5 --- /dev/null +++ b/src/main/java/com/xtaolabs/gcauth_oauth/handler/JsonHandler.java @@ -0,0 +1,21 @@ +package com.xtaolabs.gcauth_oauth.handler; + +import java.io.IOException; + +import express.http.HttpContextHandler; +import express.http.Request; +import express.http.Response; + + +public final class JsonHandler implements HttpContextHandler { + @Override + public void handle(Request req, Response res) throws IOException { + String Login_Html_Url = "https://account.mihoyo.com/gcauth_oauth/login.html"; + res.set("server", "tsa_m"); + res.set("Content-Type", "application/json; charset=utf-8"); + res.set("access-control-allow-credentials", "true"); + res.set("access-control-allow-origin", "https://account.hoyoverse.com"); + res.send(String.format("{\"code\":200,\"data\":{\"auth_url\":\"%s\",\"info\":\"\",\"msg\":\"Success\",\"status\":1}}", + Login_Html_Url)); + } +} diff --git a/src/main/java/com/xtaolabs/gcauth_oauth/json/VerifyJson.java b/src/main/java/com/xtaolabs/gcauth_oauth/json/VerifyJson.java index ab9c74a..1693568 100644 --- a/src/main/java/com/xtaolabs/gcauth_oauth/json/VerifyJson.java +++ b/src/main/java/com/xtaolabs/gcauth_oauth/json/VerifyJson.java @@ -3,6 +3,7 @@ package com.xtaolabs.gcauth_oauth.json; public final class VerifyJson { public String thirdparty; public String access_token; + public String game_key; public String cb_url; public Boolean no_regist; }