diff --git a/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs b/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs index 9e4d9b5d2b..11931b5f47 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs @@ -209,7 +209,7 @@ namespace Umbraco.Web.BackOffice.Controllers else { AddModelErrors(result); - return new ValidationErrorResult(ModelState); + return new ValidationErrorResult(new SimpleValidationModel(ModelState.ToErrorDictionary())); } } @@ -470,7 +470,7 @@ namespace Umbraco.Web.BackOffice.Controllers { if (ModelState.IsValid == false) { - return new ValidationErrorResult(ModelState); + return new ValidationErrorResult(new SimpleValidationModel(ModelState.ToErrorDictionary())); } var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); diff --git a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs index 3a3734160d..36f1a7455f 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs @@ -185,7 +185,7 @@ namespace Umbraco.Web.BackOffice.Controllers // so that is why it is being used here. ModelState.AddModelError("value", result.Errors.ToErrorMessage()); - return new ValidationErrorResult(ModelState); + return new ValidationErrorResult(new SimpleValidationModel(ModelState.ToErrorDictionary())); } //They've successfully set their password, we can now update their user account to be approved diff --git a/src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs index 452ff8b5e0..4cc1f80f9e 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs @@ -15,6 +15,7 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Core.Security; using Umbraco.Core.Serialization; using Umbraco.Core.Services; +using Umbraco.Extensions; using Umbraco.Web.BackOffice.Filters; using Umbraco.Web.Common.ActionsResults; using Umbraco.Web.Common.Attributes; @@ -302,7 +303,7 @@ namespace Umbraco.Web.BackOffice.Controllers catch (DuplicateNameException ex) { ModelState.AddModelError("Name", ex.Message); - return new ValidationErrorResult(ModelState); + return new ValidationErrorResult(new SimpleValidationModel(ModelState.ToErrorDictionary())); } // map back to display model, and return diff --git a/src/Umbraco.Web.BackOffice/Controllers/DictionaryController.cs b/src/Umbraco.Web.BackOffice/Controllers/DictionaryController.cs index 94ada7e3aa..6a03c6ef89 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/DictionaryController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/DictionaryController.cs @@ -15,6 +15,7 @@ using Constants = Umbraco.Core.Constants; using Umbraco.Core.Configuration.Models; using Microsoft.Extensions.Options; using Microsoft.AspNetCore.Authorization; +using Umbraco.Extensions; using Umbraco.Web.Common.ActionsResults; using Umbraco.Web.Common.Authorization; @@ -224,7 +225,7 @@ namespace Umbraco.Web.BackOffice.Controllers userCulture, new Dictionary { { "0", dictionary.Name } }); ModelState.AddModelError("Name", message); - return new ValidationErrorResult(ModelState); + return new ValidationErrorResult(new SimpleValidationModel(ModelState.ToErrorDictionary())); } dictionaryItem.ItemKey = dictionary.Name; diff --git a/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs b/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs index 7fbc018a1e..c011f67279 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs @@ -10,6 +10,7 @@ using Umbraco.Core.Configuration.Models; using Umbraco.Core.Mapping; using Umbraco.Core.Models; using Umbraco.Core.Services; +using Umbraco.Extensions; using Umbraco.Web.Common.ActionsResults; using Umbraco.Web.Common.Attributes; using Umbraco.Web.Common.Authorization; @@ -114,7 +115,7 @@ namespace Umbraco.Web.BackOffice.Controllers public ActionResult SaveLanguage(Language language) { if (!ModelState.IsValid) - return new ValidationErrorResult(ModelState); + return new ValidationErrorResult(new SimpleValidationModel(ModelState.ToErrorDictionary())); // this is prone to race conditions but the service will not let us proceed anyways var existingByCulture = _localizationService.GetLanguageByIsoCode(language.IsoCode); @@ -130,7 +131,7 @@ namespace Umbraco.Web.BackOffice.Controllers { //someone is trying to create a language that already exist ModelState.AddModelError("IsoCode", "The language " + language.IsoCode + " already exists"); - return new ValidationErrorResult(ModelState); + return new ValidationErrorResult(new SimpleValidationModel(ModelState.ToErrorDictionary())); } var existingById = language.Id != default ? _localizationService.GetLanguageById(language.Id) : null; @@ -147,7 +148,7 @@ namespace Umbraco.Web.BackOffice.Controllers catch (CultureNotFoundException) { ModelState.AddModelError("IsoCode", "No Culture found with name " + language.IsoCode); - return new ValidationErrorResult(ModelState); + return new ValidationErrorResult(new SimpleValidationModel(ModelState.ToErrorDictionary())); } // create it (creating a new language cannot create a fallback cycle) @@ -170,7 +171,7 @@ namespace Umbraco.Web.BackOffice.Controllers if (existingById.IsDefault && !language.IsDefault) { ModelState.AddModelError("IsDefault", "Cannot un-default the default language."); - return new ValidationErrorResult(ModelState); + return new ValidationErrorResult(new SimpleValidationModel(ModelState.ToErrorDictionary())); } existingById.IsDefault = language.IsDefault; @@ -185,12 +186,12 @@ namespace Umbraco.Web.BackOffice.Controllers if (!languages.ContainsKey(existingById.FallbackLanguageId.Value)) { ModelState.AddModelError("FallbackLanguage", "The selected fall back language does not exist."); - return new ValidationErrorResult(ModelState); + return new ValidationErrorResult(new SimpleValidationModel(ModelState.ToErrorDictionary())); } if (CreatesCycle(existingById, languages)) { ModelState.AddModelError("FallbackLanguage", $"The selected fall back language {languages[existingById.FallbackLanguageId.Value].IsoCode} would create a circular path."); - return new ValidationErrorResult(ModelState); + return new ValidationErrorResult(new SimpleValidationModel(ModelState.ToErrorDictionary())); } } diff --git a/src/Umbraco.Web.BackOffice/Controllers/PackageController.cs b/src/Umbraco.Web.BackOffice/Controllers/PackageController.cs index 57f49bdc23..d900076e03 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/PackageController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/PackageController.cs @@ -10,9 +10,11 @@ using Microsoft.Net.Http.Headers; using Semver; using Umbraco.Core; using Umbraco.Core.Hosting; +using Umbraco.Core.Models; using Umbraco.Core.Models.Packaging; using Umbraco.Core.Security; using Umbraco.Core.Services; +using Umbraco.Extensions; using Umbraco.Web.Common.ActionsResults; using Umbraco.Web.Common.Attributes; using Umbraco.Web.Common.Authorization; @@ -67,7 +69,7 @@ namespace Umbraco.Web.BackOffice.Controllers public ActionResult PostSavePackage(PackageDefinition model) { if (ModelState.IsValid == false) - return new ValidationErrorResult(ModelState); + return new ValidationErrorResult(new SimpleValidationModel(ModelState.ToErrorDictionary())); //save it if (!_packagingService.SaveCreatedPackage(model)) diff --git a/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs b/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs index 6a7d8a468c..fd2623ceab 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs @@ -704,7 +704,7 @@ namespace Umbraco.Web.BackOffice.Controllers ModelState.AddModelError(memberName, passwordChangeResult.Result.ChangeError.ErrorMessage); } - return new ValidationErrorResult(ModelState); + return new ValidationErrorResult(new SimpleValidationModel(ModelState.ToErrorDictionary())); }