class SiteTermsController {

    @PostMapping("new-terms-and-conditions")
    public String agreeNewTermsAndConditions(HttpServletRequest request,
                                             HttpServletResponse response,
                                             UserResource loggedInUser,
                                             @Valid @ModelAttribute(name = "form") NewSiteTermsAndConditionsForm form,
                                             @SuppressWarnings("unused") BindingResult bindingResult,
                                             ValidationHandler validationHandler) {
        Supplier<String> failureView = () -> newTermsAndConditions(form);

        return validationHandler.failNowOrSucceedWith(failureView, () -> {
            RestResult<Void> updateResult = userRestService.agreeNewSiteTermsAndConditions(loggedInUser.getId());

            return validationHandler.addAnyErrors(updateResult, fieldErrorsToFieldErrors(), asGlobalErrors())
                    .failNowOrSucceedWith(failureView, redirectHandler(request, response));
        });
    }

}