Fixed WebUserAuthException when viewing "/" in HTTPS mode.

This commit is contained in:
Rsl1122 2018-02-07 11:39:16 +02:00
parent bc1036572f
commit af3bdc642d

View File

@ -4,7 +4,6 @@
*/
package com.djrapitops.plan.system.webserver.pages;
import com.djrapitops.plan.api.exceptions.WebUserAuthException;
import com.djrapitops.plan.api.exceptions.connection.WebException;
import com.djrapitops.plan.data.WebUser;
import com.djrapitops.plan.system.webserver.Request;
@ -12,8 +11,6 @@ import com.djrapitops.plan.system.webserver.ResponseHandler;
import com.djrapitops.plan.system.webserver.auth.Authentication;
import com.djrapitops.plan.system.webserver.response.DefaultResponses;
import com.djrapitops.plan.system.webserver.response.Response;
import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse;
import com.djrapitops.plugin.api.utility.log.Log;
import java.util.Collections;
import java.util.List;
@ -21,7 +18,7 @@ import java.util.Optional;
/**
* PageHandler for / page (Address root).
*
* <p>
* Not Available if Authentication is not enabled.
*
* @author Rsl1122
@ -41,23 +38,18 @@ public class RootPageHandler extends PageHandler {
return DefaultResponses.BASIC_AUTH.get();
}
try {
WebUser webUser = auth.get().getWebUser();
WebUser webUser = auth.get().getWebUser();
int permLevel = webUser.getPermLevel();
switch (permLevel) {
case 0:
return responseHandler.getPageHandler("server").getResponse(request, Collections.emptyList());
case 1:
return responseHandler.getPageHandler("players").getResponse(request, Collections.emptyList());
case 2:
return responseHandler.getPageHandler("player").getResponse(request, Collections.singletonList(webUser.getName()));
default:
return responseHandler.forbiddenResponse();
}
} catch (WebUserAuthException e) {
Log.toLog(this.getClass(), e);
return new InternalErrorResponse("/", e);
int permLevel = webUser.getPermLevel();
switch (permLevel) {
case 0:
return responseHandler.getPageHandler("server").getResponse(request, Collections.emptyList());
case 1:
return responseHandler.getPageHandler("players").getResponse(request, Collections.emptyList());
case 2:
return responseHandler.getPageHandler("player").getResponse(request, Collections.singletonList(webUser.getName()));
default:
return responseHandler.forbiddenResponse();
}
}