2024-01-31 10:40:58 +01:00
using Microsoft.AspNetCore.Authorization ;
using Microsoft.AspNetCore.Mvc ;
using Umbraco.Cms.Api.Management.ViewModels.Document ;
using Umbraco.Cms.Core.Actions ;
2024-02-29 09:41:56 +00:00
using Umbraco.Cms.Core.Security.Authorization ;
2024-01-31 10:40:58 +01:00
using Umbraco.Cms.Web.Common.Authorization ;
using Umbraco.Extensions ;
namespace Umbraco.Cms.Api.Management.Controllers.Document ;
public abstract class UpdateDocumentControllerBase : DocumentControllerBase
{
private readonly IAuthorizationService _authorizationService ;
2024-03-01 10:45:19 +01:00
protected UpdateDocumentControllerBase ( IAuthorizationService authorizationService )
= > _authorizationService = authorizationService ;
2024-01-31 10:40:58 +01:00
2024-03-01 10:45:19 +01:00
protected async Task < IActionResult > HandleRequest ( Guid id , UpdateDocumentRequestModel requestModel , Func < Task < IActionResult > > authorizedHandler )
2024-01-31 10:40:58 +01:00
{
2024-09-18 13:10:15 +02:00
// TODO This have temporarily been uncommented, to support the client sends values from all cultures, even when the user do not have access to the languages.
// The values are ignored in the ContentEditingService
2024-01-31 10:40:58 +01:00
2024-09-18 13:10:15 +02:00
// IEnumerable<string> cultures = requestModel.Variants
// .Where(v => v.Culture is not null)
// .Select(v => v.Culture!);
// AuthorizationResult authorizationResult = await _authorizationService.AuthorizeResourceAsync(
// User,
// ContentPermissionResource.WithKeys(ActionUpdate.ActionLetter, id, cultures),
// AuthorizationPolicies.ContentPermissionByResource);
//
// if (!authorizationResult.Succeeded)
// {
// return Forbidden();
// }
2024-01-31 10:40:58 +01:00
2024-03-01 10:45:19 +01:00
return await authorizedHandler ( ) ;
2024-01-31 10:40:58 +01:00
}
}