Search in sources :

Example 1 with DatarouterPermissionRequest

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));
}
Also used : MessageMav(io.datarouter.web.handler.mav.imp.MessageMav) DatarouterUser(io.datarouter.web.user.databean.DatarouterUser) DatarouterPermissionRequest(io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequest) OptionalString(io.datarouter.web.handler.types.optional.OptionalString) InContextRedirectMav(io.datarouter.web.handler.mav.imp.InContextRedirectMav) OptionalString(io.datarouter.web.handler.types.optional.OptionalString) Date(java.util.Date) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 2 with DatarouterPermissionRequest

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);
}
Also used : PermissionRequestDto(io.datarouter.auth.web.DatarouterPermissionRequestHandler.PermissionRequestDto) ZoneId(java.time.ZoneId) DatarouterPermissionRequest(io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequest)

Aggregations

DatarouterPermissionRequest (io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequest)2 PermissionRequestDto (io.datarouter.auth.web.DatarouterPermissionRequestHandler.PermissionRequestDto)1 BaseHandler (io.datarouter.web.handler.BaseHandler)1 InContextRedirectMav (io.datarouter.web.handler.mav.imp.InContextRedirectMav)1 MessageMav (io.datarouter.web.handler.mav.imp.MessageMav)1 OptionalString (io.datarouter.web.handler.types.optional.OptionalString)1 DatarouterUser (io.datarouter.web.user.databean.DatarouterUser)1 ZoneId (java.time.ZoneId)1 Date (java.util.Date)1