use of io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequest in project datarouter by hotpads.
the class DatarouterPermissionRequestHandler method submit.
@Handler
private Mav submit(OptionalString specifics) {
if (!authenticationConfig.useDatarouterAuthentication()) {
return new MessageMav(noDatarouterAuthentication());
}
String reason = params.required(P_REASON);
if (StringTool.isEmpty(reason)) {
throw new IllegalArgumentException("Reason is required.");
}
String specificString = specifics.orElse("");
DatarouterUser user = getCurrentUser();
datarouterPermissionRequestDao.createPermissionRequest(new DatarouterPermissionRequest(user.getId(), new Date(), "reason: " + reason + ", specifics: " + specificString, null, null));
sendRequestEmail(user, reason, specificString);
// not just requestor, so send them to the home page after they make their request
if (user.getRoles().size() > 1) {
return new InContextRedirectMav(request, paths.home);
}
return showForm(new OptionalString(null), new OptionalString(null));
}
use of io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequest in project datarouter by hotpads.
the class AdminEditUserHandler method buildPermissionRequestDto.
// TODO DATAROUTER-2789
private PermissionRequestDto buildPermissionRequestDto(Entry<DatarouterPermissionRequest, Optional<String>> entry) {
ZoneId zoneId = currentUserSessionInfoService.getZoneId(getRequest());
DatarouterPermissionRequest request = entry.getKey();
return new PermissionRequestDto(request.getKey().getRequestTime(), request.getRequestText(), request.getResolutionTime(), entry.getValue().orElse(null), zoneId);
}
Aggregations