use of com.djrapitops.plan.delivery.web.resolver.request.WebUser in project Plan by plan-player-analytics.
the class ServerPageResolver method canAccess.
@Override
public boolean canAccess(Request request) {
String firstPart = request.getPath().getPart(0).orElse("");
WebUser permissions = request.getUser().orElse(new WebUser(""));
boolean forServerPage = "server".equalsIgnoreCase(firstPart) && permissions.hasPermission("page.server");
boolean forNetworkPage = "network".equalsIgnoreCase(firstPart) && permissions.hasPermission("page.network");
return forServerPage || forNetworkPage;
}
use of com.djrapitops.plan.delivery.web.resolver.request.WebUser in project Plan by plan-player-analytics.
the class UserJSONResolver method getResponse.
private Response getResponse(Request request) {
if (!webServer.get().isAuthRequired()) {
return Response.builder().setStatus(404).setJSONContent("{}").build();
}
WebUser user = request.getUser().orElseThrow(() -> new WebUserAuthException(FailReason.NO_USER_PRESENT));
Map<String, Object> json = new HashMap<>();
json.put("username", user.getUsername());
json.put("linkedTo", user.getName());
json.put("permissions", user.getPermissions());
return Response.builder().setJSONContent(json).build();
}
Aggregations