Ensure redirect not sent twice when verifying admin route on initial registration

This commit is contained in:
Josh Stark 2019-03-17 13:04:32 +00:00
parent 6ce1e99438
commit 26322ade92
2 changed files with 6 additions and 1 deletions

View File

@ -100,6 +100,9 @@ public class WebServer {
return () -> before(path, (request, response) -> {
if (response.raw().isCommitted())
return;
Session session = request.session(false);
if (null == session)

View File

@ -23,6 +23,8 @@ import spark.Filter;
import spark.Request;
import spark.Response;
import static spark.Spark.halt;
/**
* <p>
* Forces the maintainer of Fleet to set up an initial user before running Fleet.
@ -51,7 +53,7 @@ public class InitialUserFilterRoute implements Filter {
if (databaseAuthenticationEnabled) {
if (!initialUserNeedsConfiguring() && "/admin/setup".equals(request.pathInfo())) {
response.redirect("/admin");
halt(401);
}
else if (initialUserNeedsConfiguring() && !pathIsExempted(request.pathInfo())) {