Skip to content

Commit

Permalink
Make the oauth response screen customizable HTML (SKCraft#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgehog1029 authored Nov 4, 2022
2 parents 13b6a77 + 68bd6c3 commit f45033e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import com.google.common.base.Charsets;
import com.google.common.base.Splitter;
import com.skcraft.launcher.Launcher;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import lombok.extern.java.Log;
import org.apache.commons.io.IOUtils;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.util.Map;
import java.util.concurrent.Executor;
Expand Down Expand Up @@ -56,7 +59,14 @@ public void handle(HttpExchange httpExchange) throws IOException {
OauthHttpHandler.this.notifyAll();
}

byte[] response = "OK: you can close the browser now".getBytes(Charsets.UTF_8);
byte[] response;
InputStream is = Launcher.class.getResourceAsStream("login.html");
if (is != null) {
response = IOUtils.toByteArray(is);
} else {
response = "Unable to fetch resource login.html".getBytes(Charsets.UTF_8);
}

httpExchange.sendResponseHeaders(200, response.length);
httpExchange.getResponseBody().write(response);
httpExchange.getResponseBody().flush();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>OK: you can close the browser now</p>

0 comments on commit f45033e

Please sign in to comment.