mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-08 17:37:34 +01:00
Fixed boot issue introduced in previous commit
This commit is contained in:
parent
799e28f14a
commit
4da469dcf4
@ -86,11 +86,7 @@ public class ResponseHandler extends TreePageHandler {
|
|||||||
registerPage("network", serverPageHandler);
|
registerPage("network", serverPageHandler);
|
||||||
registerPage("server", serverPageHandler);
|
registerPage("server", serverPageHandler);
|
||||||
|
|
||||||
if (webServer.get().isAuthRequired()) {
|
registerPage("", new RootPageHandler(responseFactory, webServer.get(), serverInfo));
|
||||||
registerPage("", new RootPageHandler(responseFactory, serverInfo));
|
|
||||||
} else {
|
|
||||||
registerPage("", responseFactory.redirectResponse(serverInfo.getServer().isProxy() ? "/network" : "/server"), 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
registerPage("v1", rootJSONHandler);
|
registerPage("v1", rootJSONHandler);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import com.djrapitops.plan.data.WebUser;
|
|||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
import com.djrapitops.plan.system.webserver.Request;
|
import com.djrapitops.plan.system.webserver.Request;
|
||||||
import com.djrapitops.plan.system.webserver.RequestTarget;
|
import com.djrapitops.plan.system.webserver.RequestTarget;
|
||||||
|
import com.djrapitops.plan.system.webserver.WebServer;
|
||||||
import com.djrapitops.plan.system.webserver.auth.Authentication;
|
import com.djrapitops.plan.system.webserver.auth.Authentication;
|
||||||
import com.djrapitops.plan.system.webserver.response.RedirectResponse;
|
import com.djrapitops.plan.system.webserver.response.RedirectResponse;
|
||||||
import com.djrapitops.plan.system.webserver.response.Response;
|
import com.djrapitops.plan.system.webserver.response.Response;
|
||||||
@ -38,15 +39,21 @@ import java.util.Optional;
|
|||||||
public class RootPageHandler implements PageHandler {
|
public class RootPageHandler implements PageHandler {
|
||||||
|
|
||||||
private final ResponseFactory responseFactory;
|
private final ResponseFactory responseFactory;
|
||||||
|
private final WebServer webServer;
|
||||||
private final ServerInfo serverInfo;
|
private final ServerInfo serverInfo;
|
||||||
|
|
||||||
public RootPageHandler(ResponseFactory responseFactory, ServerInfo serverInfo) {
|
public RootPageHandler(ResponseFactory responseFactory, WebServer webServer, ServerInfo serverInfo) {
|
||||||
this.responseFactory = responseFactory;
|
this.responseFactory = responseFactory;
|
||||||
|
this.webServer = webServer;
|
||||||
this.serverInfo = serverInfo;
|
this.serverInfo = serverInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response getResponse(Request request, RequestTarget target) throws WebException {
|
public Response getResponse(Request request, RequestTarget target) throws WebException {
|
||||||
|
if (!webServer.isAuthRequired()) {
|
||||||
|
return responseFactory.redirectResponse(serverInfo.getServer().isProxy() ? "/network" : "/server");
|
||||||
|
}
|
||||||
|
|
||||||
Optional<Authentication> auth = request.getAuth();
|
Optional<Authentication> auth = request.getAuth();
|
||||||
if (!auth.isPresent()) {
|
if (!auth.isPresent()) {
|
||||||
return responseFactory.basicAuth();
|
return responseFactory.basicAuth();
|
||||||
|
Loading…
Reference in New Issue
Block a user