Refactoring the use of ValidationErrorResult with the build-in types for status response results
This commit is contained in:
@@ -349,7 +349,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
// by our angular helper because it thinks that we need to re-perform the request once we are
|
||||
// authorized and we don't want to return a 403 because angular will show a warning message indicating
|
||||
// that the user doesn't have access to perform this function, we just want to return a normal invalid message.
|
||||
return new ValidationErrorResult(null);
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Core;
|
||||
@@ -258,10 +257,10 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
snippets = _fileService.GetPartialViewSnippetNames();
|
||||
break;
|
||||
default:
|
||||
return new ValidationErrorResult(type, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return snippets.Select(snippet => new SnippetDisplay() {Name = snippet.SplitPascalCasing(_shortStringHelper).ToFirstUpperInvariant(), FileName = snippet}).ToList();
|
||||
return snippets.Select(snippet => new SnippetDisplay() { Name = snippet.SplitPascalCasing(_shortStringHelper).ToFirstUpperInvariant(), FileName = snippet }).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Net.Mime;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -384,7 +383,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
return GetById(guidUdi.Guid);
|
||||
}
|
||||
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -399,7 +398,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var contentType = _contentTypeService.Get(contentTypeAlias);
|
||||
if (contentType == null)
|
||||
{
|
||||
return new ValidationErrorResult(contentType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return GetEmpty(contentType, parentId);
|
||||
@@ -417,7 +416,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var contentType = _contentTypeService.Get(contentTypeKey);
|
||||
if (contentType == null)
|
||||
{
|
||||
return new ValidationErrorResult(contentType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return GetEmpty(contentType, parentId);
|
||||
@@ -446,7 +445,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var blueprint = _contentService.GetBlueprintById(blueprintId);
|
||||
if (blueprint == null)
|
||||
{
|
||||
return new ValidationErrorResult(blueprint, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
blueprint.Id = 0;
|
||||
@@ -2022,14 +2021,14 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new ValidationErrorResult(model, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var contentService = _contentService;
|
||||
var toMove = contentService.GetById(model.Id);
|
||||
if (toMove == null)
|
||||
{
|
||||
return new ValidationErrorResult(toMove, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
if (model.ParentId < 0)
|
||||
{
|
||||
@@ -2045,7 +2044,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var parent = contentService.GetById(model.ParentId);
|
||||
if (parent == null)
|
||||
{
|
||||
return new ValidationErrorResult(parent, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var parentContentType = _contentTypeService.Get(parent.ContentTypeId);
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Mime;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
@@ -121,7 +120,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var ct = _contentTypeService.Get(id);
|
||||
if (ct == null)
|
||||
{
|
||||
return new ValidationErrorResult(ct, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var dto = _umbracoMapper.Map<IContentType, DocumentTypeDisplay>(ct);
|
||||
@@ -138,7 +137,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var contentType = _contentTypeService.Get(id);
|
||||
if (contentType == null)
|
||||
{
|
||||
return new ValidationErrorResult(contentType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var dto = _umbracoMapper.Map<IContentType, DocumentTypeDisplay>(contentType);
|
||||
@@ -154,12 +153,12 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var guidUdi = id as GuidUdi;
|
||||
if (guidUdi == null)
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
var contentType = _contentTypeService.Get(guidUdi.Guid);
|
||||
if (contentType == null)
|
||||
{
|
||||
return new ValidationErrorResult(contentType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var dto = _umbracoMapper.Map<IContentType, DocumentTypeDisplay>(contentType);
|
||||
@@ -177,7 +176,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var foundType = _contentTypeService.Get(id);
|
||||
if (foundType == null)
|
||||
{
|
||||
return new ValidationErrorResult(foundType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_contentTypeService.Delete(foundType, _backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser.Id);
|
||||
@@ -254,7 +253,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
|
||||
if (dataTypeDiff == null)
|
||||
{
|
||||
return new ValidationErrorResult(dataTypeDiff, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var configuration = _dataTypeService.GetDataType(id).Configuration;
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Mime;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Umbraco.Core;
|
||||
@@ -92,7 +91,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
if (contentTypeId > 0)
|
||||
{
|
||||
source = ContentTypeService.Get(contentTypeId);
|
||||
if (source == null) return new ValidationErrorResult(source, StatusCodes.Status404NotFound);
|
||||
if (source == null) return NotFound();
|
||||
}
|
||||
allContentTypes = ContentTypeService.GetAll().Cast<IContentTypeComposition>().ToArray();
|
||||
break;
|
||||
@@ -101,7 +100,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
if (contentTypeId > 0)
|
||||
{
|
||||
source =MediaTypeService.Get(contentTypeId);
|
||||
if (source == null) return new ValidationErrorResult(source, StatusCodes.Status404NotFound);
|
||||
if (source == null) return NotFound();
|
||||
}
|
||||
allContentTypes =MediaTypeService.GetAll().Cast<IContentTypeComposition>().ToArray();
|
||||
break;
|
||||
@@ -110,7 +109,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
if (contentTypeId > 0)
|
||||
{
|
||||
source = MemberTypeService.Get(contentTypeId);
|
||||
if (source == null) return new ValidationErrorResult(source, StatusCodes.Status404NotFound);
|
||||
if (source == null) return NotFound();
|
||||
}
|
||||
allContentTypes = MemberTypeService.GetAll().Cast<IContentTypeComposition>().ToArray();
|
||||
break;
|
||||
@@ -205,7 +204,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
}
|
||||
|
||||
if (source == null)
|
||||
return new ValidationErrorResult(source, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
id = source.Id;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,9 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Mime;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Core;
|
||||
@@ -97,7 +95,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var dataType = _dataTypeService.GetDataType(id);
|
||||
if (dataType == null)
|
||||
{
|
||||
return new ValidationErrorResult(dataType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return _umbracoMapper.Map<IDataType, DataTypeDisplay>(dataType);
|
||||
@@ -114,7 +112,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var dataType = _dataTypeService.GetDataType(id);
|
||||
if (dataType == null)
|
||||
{
|
||||
return new ValidationErrorResult(dataType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return _umbracoMapper.Map<IDataType, DataTypeDisplay>(dataType);
|
||||
@@ -130,12 +128,12 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var guidUdi = id as GuidUdi;
|
||||
if (guidUdi == null)
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
var dataType = _dataTypeService.GetDataType(guidUdi.Guid);
|
||||
if (dataType == null)
|
||||
{
|
||||
return new ValidationErrorResult(dataType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return _umbracoMapper.Map<IDataType, DataTypeDisplay>(dataType);
|
||||
@@ -153,7 +151,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var foundType = _dataTypeService.GetDataType(id);
|
||||
if (foundType == null)
|
||||
{
|
||||
return new ValidationErrorResult(foundType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
|
||||
_dataTypeService.Delete(foundType, currentUser.Id);
|
||||
@@ -179,7 +177,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var dt = _dataTypeService.GetDataType(Constants.Conventions.DataTypes.ListViewPrefix + contentTypeAlias);
|
||||
if (dt == null)
|
||||
{
|
||||
return new ValidationErrorResult(dt, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return _umbracoMapper.Map<IDataType, DataTypeDisplay>(dt);
|
||||
@@ -229,7 +227,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var dataType = _dataTypeService.GetDataType(dataTypeId);
|
||||
if (dataType == null)
|
||||
{
|
||||
return new ValidationErrorResult(dataType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
//now, lets check if the data type has the current editor selected, if that is true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -17,7 +17,6 @@ using Umbraco.Core.Trees;
|
||||
using Umbraco.Core.Xml;
|
||||
using Umbraco.Extensions;
|
||||
using Umbraco.Web.BackOffice.ModelBinders;
|
||||
using Umbraco.Web.Common.ActionsResults;
|
||||
using Umbraco.Web.Common.Attributes;
|
||||
using Umbraco.Web.Common.ModelBinders;
|
||||
using Umbraco.Web.Models;
|
||||
@@ -237,7 +236,8 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
return new ActionResult<IEnumerable<int>>(GetPath(guidUdi.Guid, type));
|
||||
}
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -251,7 +251,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var intId = _entityService.GetId(udi);
|
||||
if (!intId.Success)
|
||||
return new ValidationErrorResult(intId.Result, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
UmbracoEntityTypes entityType;
|
||||
switch (udi.EntityType)
|
||||
{
|
||||
@@ -265,7 +265,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
entityType = UmbracoEntityTypes.Member;
|
||||
break;
|
||||
default:
|
||||
return new ValidationErrorResult(udi.EntityType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
return GetUrl(intId.Result, entityType, culture);
|
||||
}
|
||||
@@ -357,7 +357,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var intId = _entityService.GetId(id);
|
||||
if (!intId.Success)
|
||||
return new ValidationErrorResult(intId.Result, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
return GetUrlAndAnchors(intId.Result, culture);
|
||||
}
|
||||
@@ -422,7 +422,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
return GetResultForKey(guidUdi.Guid, type);
|
||||
}
|
||||
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -443,7 +443,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
if (ids == null)
|
||||
{
|
||||
return new ValidationErrorResult(ids, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return new ActionResult<IEnumerable<EntityBasic>>(GetResultForIds(ids, type));
|
||||
@@ -465,7 +465,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
if (ids == null)
|
||||
{
|
||||
return new ValidationErrorResult(ids, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return new ActionResult<IEnumerable<EntityBasic>>(GetResultForKeys(ids, type));
|
||||
@@ -489,7 +489,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
if (ids == null)
|
||||
{
|
||||
return new ValidationErrorResult(ids, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (ids.Length == 0)
|
||||
@@ -506,7 +506,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
return new ActionResult<IEnumerable<EntityBasic>>(GetResultForKeys(ids.Select(x => ((GuidUdi)x).Guid).ToArray(), type));
|
||||
}
|
||||
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -580,13 +580,13 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
if (Guid.TryParse(id, out _))
|
||||
{
|
||||
//Not supported currently
|
||||
return new ValidationErrorResult(id, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (UdiParser.TryParse(id, out _))
|
||||
{
|
||||
//Not supported currently
|
||||
return new ValidationErrorResult(id, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
//so we don't have an INT, GUID or UDI, it's just a string, so now need to check if it's a special id or a member type
|
||||
@@ -635,9 +635,9 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
Guid? dataTypeKey = null)
|
||||
{
|
||||
if (pageNumber <= 0)
|
||||
return new ValidationErrorResult(pageNumber, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
if (pageSize <= 0)
|
||||
return new ValidationErrorResult(pageSize, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
var objectType = ConvertToObjectType(type);
|
||||
if (objectType.HasValue)
|
||||
@@ -735,9 +735,9 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
Guid? dataTypeKey = null)
|
||||
{
|
||||
if (pageNumber <= 0)
|
||||
return new ValidationErrorResult(pageNumber, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
if (pageSize <= 0)
|
||||
return new ValidationErrorResult(pageSize, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
// re-normalize since NULL can be passed in
|
||||
filter = filter ?? string.Empty;
|
||||
@@ -980,7 +980,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var found = _entityService.Get(key, objectType.Value);
|
||||
if (found == null)
|
||||
{
|
||||
return new ValidationErrorResult(found, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
return _umbracoMapper.Map<IEntitySlim, EntityBasic>(found);
|
||||
}
|
||||
@@ -1012,7 +1012,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var found = _entityService.Get(id, objectType.Value);
|
||||
if (found == null)
|
||||
{
|
||||
return new ValidationErrorResult(found, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
return MapEntity(found);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Core;
|
||||
@@ -68,7 +66,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var macro = _macroService.GetById(macroId);
|
||||
if (macro == null)
|
||||
{
|
||||
return new ValidationErrorResult(macro, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return new ActionResult<IEnumerable<MacroParameter>>(_umbracoMapper.Map<IEnumerable<MacroParameter>>(macro).OrderBy(x => x.SortOrder));
|
||||
@@ -116,7 +114,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var m = _macroService.GetByAlias(macroAlias);
|
||||
if (m == null)
|
||||
return new ValidationErrorResult(m, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
var umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext();
|
||||
var publishedContent = umbracoContext.Content.GetById(true, pageId);
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult DeleteById(int id)
|
||||
public IActionResult DeleteById(int id)
|
||||
{
|
||||
var macro = _macroService.GetById(id);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Mime;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -126,7 +125,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var contentType = _mediaTypeService.Get(contentTypeAlias);
|
||||
if (contentType == null)
|
||||
{
|
||||
return new ValidationErrorResult(contentType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var emptyContent = _mediaService.CreateMedia("", parentId, contentType.Alias, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(Constants.Security.SuperUserId));
|
||||
@@ -221,7 +220,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
return GetById(guidUdi.Guid);
|
||||
}
|
||||
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -392,7 +391,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
return GetChildren(entity.Id, pageNumber, pageSize, orderBy, orderDirection, orderBySystemField, filter);
|
||||
}
|
||||
|
||||
return new ValidationErrorResult(entity, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -426,7 +425,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -906,14 +905,14 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new ValidationErrorResult(model, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
|
||||
var toMove = _mediaService.GetById(model.Id);
|
||||
if (toMove == null)
|
||||
{
|
||||
return new ValidationErrorResult(toMove, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
if (model.ParentId < 0)
|
||||
{
|
||||
@@ -932,7 +931,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var parent = _mediaService.GetById(model.ParentId);
|
||||
if (parent == null)
|
||||
{
|
||||
return new ValidationErrorResult(parent, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
//check if the item is allowed under this one
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Dictionary;
|
||||
@@ -83,7 +81,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var ct = _mediaTypeService.Get(id);
|
||||
if (ct == null)
|
||||
{
|
||||
return new ValidationErrorResult(ct, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var dto = _umbracoMapper.Map<IMediaType, MediaTypeDisplay>(ct);
|
||||
@@ -102,7 +100,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var mediaType = _mediaTypeService.Get(id);
|
||||
if (mediaType == null)
|
||||
{
|
||||
return new ValidationErrorResult(mediaType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var dto = _umbracoMapper.Map<IMediaType, MediaTypeDisplay>(mediaType);
|
||||
@@ -120,12 +118,12 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var guidUdi = id as GuidUdi;
|
||||
if (guidUdi == null)
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
var mediaType = _mediaTypeService.Get(guidUdi.Guid);
|
||||
if (mediaType == null)
|
||||
{
|
||||
return new ValidationErrorResult(mediaType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var dto = _umbracoMapper.Map<IMediaType, MediaTypeDisplay>(mediaType);
|
||||
@@ -145,7 +143,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var foundType = _mediaTypeService.Get(id);
|
||||
if (foundType == null)
|
||||
{
|
||||
return new ValidationErrorResult(foundType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_mediaTypeService.Delete(foundType, _backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser.Id);
|
||||
@@ -383,7 +381,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
return new ActionResult<IEnumerable<ContentTypeBasic>>(GetAllowedChildren(entity.Id));
|
||||
}
|
||||
|
||||
return new ValidationErrorResult(entity, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -404,7 +402,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -2,13 +2,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Mime;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
@@ -173,13 +171,13 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
IMember emptyContent;
|
||||
if (contentTypeAlias == null)
|
||||
{
|
||||
return new ValidationErrorResult(contentTypeAlias, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var contentType = _memberTypeService.Get(contentTypeAlias);
|
||||
if (contentType == null)
|
||||
{
|
||||
return new ValidationErrorResult(contentType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var passwordGenerator = new PasswordGenerator(_passwordConfig);
|
||||
@@ -241,7 +239,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
break;
|
||||
default:
|
||||
//we don't support anything else for members
|
||||
return new ValidationErrorResult(contentItem.Action, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
//TODO: There's 3 things saved here and we should do this all in one transaction, which we can do here by wrapping in a scope
|
||||
|
||||
@@ -2,13 +2,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Mapping;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Common.ActionsResults;
|
||||
using Umbraco.Web.Common.Attributes;
|
||||
using Umbraco.Web.Common.Authorization;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
@@ -50,7 +48,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var memberGroup = _memberGroupService.GetById(id);
|
||||
if (memberGroup == null)
|
||||
{
|
||||
return new ValidationErrorResult(memberGroup, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var dto = _umbracoMapper.Map<IMemberGroup, MemberGroupDisplay>(memberGroup);
|
||||
@@ -69,7 +67,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var memberGroup = _memberGroupService.GetById(id);
|
||||
if (memberGroup == null)
|
||||
{
|
||||
return new ValidationErrorResult(memberGroup, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return _umbracoMapper.Map<IMemberGroup, MemberGroupDisplay>(memberGroup);
|
||||
@@ -85,12 +83,12 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var guidUdi = id as GuidUdi;
|
||||
if (guidUdi == null)
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
var memberGroup = _memberGroupService.GetById(guidUdi.Guid);
|
||||
if (memberGroup == null)
|
||||
{
|
||||
return new ValidationErrorResult(memberGroup, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return _umbracoMapper.Map<IMemberGroup, MemberGroupDisplay>(memberGroup);
|
||||
@@ -109,7 +107,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var memberGroup = _memberGroupService.GetById(id);
|
||||
if (memberGroup == null)
|
||||
{
|
||||
return new ValidationErrorResult(memberGroup, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_memberGroupService.Delete(memberGroup);
|
||||
@@ -135,7 +133,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var memberGroup = id > 0 ? _memberGroupService.GetById(id) : new MemberGroup();
|
||||
if (memberGroup == null)
|
||||
{
|
||||
return new ValidationErrorResult(memberGroup, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
memberGroup.Name = saveModel.Name;
|
||||
|
||||
@@ -14,8 +14,6 @@ using Umbraco.Core.Security;
|
||||
using Umbraco.Web.Common.Attributes;
|
||||
using Umbraco.Web.Editors;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Umbraco.Web.Common.ActionsResults;
|
||||
using Umbraco.Web.Common.Authorization;
|
||||
|
||||
namespace Umbraco.Web.BackOffice.Controllers
|
||||
@@ -70,7 +68,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var mt = _memberTypeService.Get(id);
|
||||
if (mt == null)
|
||||
{
|
||||
return new ValidationErrorResult(mt, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var dto =_umbracoMapper.Map<IMemberType, MemberTypeDisplay>(mt);
|
||||
@@ -88,7 +86,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var memberType = _memberTypeService.Get(id);
|
||||
if (memberType == null)
|
||||
{
|
||||
return new ValidationErrorResult(memberType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var dto = _umbracoMapper.Map<IMemberType, MemberTypeDisplay>(memberType);
|
||||
@@ -105,12 +103,12 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var guidUdi = id as GuidUdi;
|
||||
if (guidUdi == null)
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
var memberType = _memberTypeService.Get(guidUdi.Guid);
|
||||
if (memberType == null)
|
||||
{
|
||||
return new ValidationErrorResult(memberType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var dto = _umbracoMapper.Map<IMemberType, MemberTypeDisplay>(memberType);
|
||||
@@ -129,7 +127,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var foundType = _memberTypeService.Get(id);
|
||||
if (foundType == null)
|
||||
{
|
||||
return new ValidationErrorResult(foundType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_memberTypeService.Delete(foundType, _backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser.Id);
|
||||
@@ -212,7 +210,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
if (ct.IsSensitiveProperty(foundOnContentType.Alias) && prop.IsSensitiveData == false)
|
||||
{
|
||||
//if these don't match, then we cannot continue, this user is not allowed to change this value
|
||||
return new ValidationErrorResult(ct, StatusCodes.Status403Forbidden);
|
||||
return Forbid();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,7 +219,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
//if it is new, then we can just verify if any property has sensitive data turned on which is not allowed
|
||||
if (props.Any(prop => prop.IsSensitiveData))
|
||||
{
|
||||
return new ValidationErrorResult(props, StatusCodes.Status403Forbidden);
|
||||
return Forbid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using Semver;
|
||||
@@ -50,7 +49,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var package = _packagingService.GetCreatedPackageById(id);
|
||||
if (package == null)
|
||||
return new ValidationErrorResult(package, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
return package;
|
||||
}
|
||||
@@ -130,7 +129,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
public ActionResult<PackageDefinition> GetInstalledPackageById(int id)
|
||||
{
|
||||
var pack = _packagingService.GetInstalledPackageById(id);
|
||||
if (pack == null) return new ValidationErrorResult(pack, StatusCodes.Status404NotFound);
|
||||
if (pack == null) return NotFound();
|
||||
return pack;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -14,7 +13,6 @@ using Constants = Umbraco.Core.Constants;
|
||||
using Umbraco.Core.Mapping;
|
||||
using Umbraco.Web.Common.Attributes;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Umbraco.Web.Common.ActionsResults;
|
||||
using Umbraco.Web.Common.Authorization;
|
||||
|
||||
@@ -56,7 +54,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
|
||||
if (relationType == null)
|
||||
{
|
||||
return new ValidationErrorResult(relationType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var display = _umbracoMapper.Map<IRelationType, RelationTypeDisplay>(relationType);
|
||||
@@ -74,7 +72,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var relationType = _relationService.GetRelationTypeById(id);
|
||||
if (relationType == null)
|
||||
{
|
||||
return new ValidationErrorResult(relationType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
return _umbracoMapper.Map<IRelationType, RelationTypeDisplay>(relationType);
|
||||
}
|
||||
@@ -89,12 +87,12 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var guidUdi = id as GuidUdi;
|
||||
if (guidUdi == null)
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
var relationType = _relationService.GetRelationTypeById(guidUdi.Guid);
|
||||
if (relationType == null)
|
||||
{
|
||||
return new ValidationErrorResult(relationType, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
return _umbracoMapper.Map<IRelationType, RelationTypeDisplay>(relationType);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -10,7 +9,6 @@ using Umbraco.Core.Mapping;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.Common.ActionsResults;
|
||||
using Umbraco.Web.Common.Attributes;
|
||||
using Umbraco.Web.Common.Authorization;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
@@ -66,7 +64,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var template = _fileService.GetTemplate(id);
|
||||
if (template == null)
|
||||
return new ValidationErrorResult(template, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
return _umbracoMapper.Map<ITemplate, TemplateDisplay>(template);
|
||||
}
|
||||
@@ -82,7 +80,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var template = _fileService.GetTemplate(id);
|
||||
if (template == null)
|
||||
return new ValidationErrorResult(template, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
return _umbracoMapper.Map<ITemplate, TemplateDisplay>(template);
|
||||
}
|
||||
@@ -97,12 +95,12 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var guidUdi = id as GuidUdi;
|
||||
if (guidUdi == null)
|
||||
return new ValidationErrorResult(guidUdi, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
var template = _fileService.GetTemplate(guidUdi.Guid);
|
||||
if (template == null)
|
||||
{
|
||||
return new ValidationErrorResult(template, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return _umbracoMapper.Map<ITemplate, TemplateDisplay>(template);
|
||||
@@ -119,7 +117,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var template = _fileService.GetTemplate(id);
|
||||
if (template == null)
|
||||
return new ValidationErrorResult(template, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
_fileService.DeleteTemplate(template.Alias);
|
||||
return Ok();
|
||||
@@ -166,7 +164,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
// update
|
||||
var template = _fileService.GetTemplate(display.Id);
|
||||
if (template == null)
|
||||
return new ValidationErrorResult(template, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
var changeMaster = template.MasterTemplateAlias != display.MasterTemplateAlias;
|
||||
var changeAlias = template.Alias != display.Alias;
|
||||
@@ -238,7 +236,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
master = _fileService.GetTemplate(display.MasterTemplateAlias);
|
||||
if (master == null)
|
||||
return new ValidationErrorResult(master, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
// we need to pass the template name as alias to keep the template file casing consistent with templates created with content
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var urls = _backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser.GetUserAvatarUrls(_appCaches.RuntimeCache, _mediaFileSystem, _imageUrlGenerator);
|
||||
if (urls == null)
|
||||
return new ValidationErrorResult("Could not access Gravatar endpoint");
|
||||
return BadRequest("Could not access Gravatar endpoint");
|
||||
|
||||
return urls;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
if (files is null)
|
||||
{
|
||||
return new ValidationErrorResult(files, StatusCodes.Status415UnsupportedMediaType);
|
||||
return new UnsupportedMediaTypeResult();
|
||||
}
|
||||
|
||||
var root = hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.TempFileUploads);
|
||||
@@ -229,7 +229,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var user = _userService.GetUserById(id);
|
||||
if (user == null)
|
||||
{
|
||||
return new ValidationErrorResult(user, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
var result = _umbracoMapper.Map<IUser, UserDisplay>(user);
|
||||
return result;
|
||||
@@ -246,7 +246,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
if (ids == null)
|
||||
{
|
||||
return new ValidationErrorResult(ids, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (ids.Length == 0)
|
||||
@@ -255,7 +255,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var users = _userService.GetUsersById(ids);
|
||||
if (users == null)
|
||||
{
|
||||
return new ValidationErrorResult(users, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var result = _umbracoMapper.MapEnumerable<IUser, UserDisplay>(users);
|
||||
@@ -342,7 +342,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
|
||||
if (ModelState.IsValid == false)
|
||||
{
|
||||
return new ValidationErrorResult(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (_securitySettings.UsernameIsEmail)
|
||||
@@ -361,7 +361,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
var canSaveUser = _userEditorAuthorizationHelper.IsAuthorized(_backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser, null, null, null, userSave.UserGroups);
|
||||
if (canSaveUser == false)
|
||||
{
|
||||
return new ValidationErrorResult(canSaveUser.Result, StatusCodes.Status401Unauthorized);
|
||||
return Unauthorized(canSaveUser.Result);
|
||||
}
|
||||
|
||||
//we want to create the user with the UserManager, this ensures the 'empty' (special) password
|
||||
@@ -419,7 +419,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
|
||||
if (ModelState.IsValid == false)
|
||||
{
|
||||
return new ValidationErrorResult(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
IUser user;
|
||||
@@ -518,7 +518,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
if (user != null && (extraCheck == null || extraCheck(user)))
|
||||
{
|
||||
ModelState.AddModelError("Email", "A user with the email already exists");
|
||||
return new ValidationErrorResult(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
return new ActionResult<IUser>(user);
|
||||
@@ -532,7 +532,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
ModelState.AddModelError(
|
||||
_securitySettings.UsernameIsEmail ? "Email" : "Username",
|
||||
"A user with the username already exists");
|
||||
return new ValidationErrorResult(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
return new ActionResult<IUser>(user);
|
||||
@@ -594,13 +594,13 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
|
||||
var found = _userService.GetUserById(intId.Result);
|
||||
if (found == null)
|
||||
return new ValidationErrorResult(found, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
|
||||
//Perform authorization here to see if the current user can actually save this user with the info being requested
|
||||
var canSaveUser = _userEditorAuthorizationHelper.IsAuthorized(_backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser, found, userSave.StartContentIds, userSave.StartMediaIds, userSave.UserGroups);
|
||||
if (canSaveUser == false)
|
||||
{
|
||||
return new ValidationErrorResult(canSaveUser.Result, StatusCodes.Status401Unauthorized);
|
||||
return Unauthorized(canSaveUser.Result);
|
||||
}
|
||||
|
||||
var hasErrors = false;
|
||||
@@ -647,7 +647,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
}
|
||||
|
||||
if (hasErrors)
|
||||
return new ValidationErrorResult(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
|
||||
//merge the save data onto the user
|
||||
var user = _umbracoMapper.Map(userSave, found);
|
||||
@@ -671,19 +671,19 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
|
||||
if (ModelState.IsValid == false)
|
||||
{
|
||||
return new ValidationErrorResult(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
var intId = changingPasswordModel.Id.TryConvertTo<int>();
|
||||
if (intId.Success == false)
|
||||
{
|
||||
return new ValidationErrorResult(intId, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var found = _userService.GetUserById(intId.Result);
|
||||
if (found == null)
|
||||
{
|
||||
return new ValidationErrorResult(found, StatusCodes.Status404NotFound);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
// TODO: Why don't we inject this? Then we can just inject a logger
|
||||
|
||||
Reference in New Issue
Block a user