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 39106d5..952a391 100644 --- a/src/main/java/com/xtaolabs/gcauth_oauth/GCAuth_OAuth.java +++ b/src/main/java/com/xtaolabs/gcauth_oauth/GCAuth_OAuth.java @@ -38,12 +38,15 @@ public class GCAuth_OAuth extends Plugin { public void loadTwitterLogin() { String folder_name = PLUGINS_FOLDER + "/GCAuth/OAuth/"; + String Login_Url = ("http" + (DISPATCH_ENCRYPTION.useEncryption ? "s" : "") + "://" + + lr(DISPATCH_INFO.accessAddress, DISPATCH_INFO.bindAddress) + ":" + + lr(DISPATCH_INFO.accessPort, DISPATCH_INFO.bindPort) + "/gcauth_oauth/login.html"); Express app = Grasscutter.getDispatchServer().getServer(); app.get("/Api/twitter_login", new JsonHandler()); app.get("/sdkTwitterLogin.html", new DispatchHttpJsonHandler( - "" + String.format("", Login_Url) )); 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 index 8d8d8e5..f45c24b 100644 --- a/src/main/java/com/xtaolabs/gcauth_oauth/handler/JsonHandler.java +++ b/src/main/java/com/xtaolabs/gcauth_oauth/handler/JsonHandler.java @@ -6,16 +6,21 @@ import express.http.HttpContextHandler; import express.http.Request; import express.http.Response; +import static emu.grasscutter.Configuration.*; +import static emu.grasscutter.Configuration.DISPATCH_INFO; + 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"; + String Login_Url = ("http" + (DISPATCH_ENCRYPTION.useEncryption ? "s" : "") + "://" + + lr(DISPATCH_INFO.accessAddress, DISPATCH_INFO.bindAddress) + ":" + + lr(DISPATCH_INFO.accessPort, DISPATCH_INFO.bindPort) + "/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)); + Login_Url)); } }