use of com.djrapitops.plan.exceptions.WebUserAuthException 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