Netcore: Introduce BackofficeSecurityAccessor (#8871)
* Introduced IWebSecurityAccessor Signed-off-by: Bjarke Berg <mail@bergmania.dk> * Fixed tests Signed-off-by: Bjarke Berg <mail@bergmania.dk> * Renamed WebSecurity to BackofficeSecurity and all related names * Fixes typos Co-authored-by: Elitsa Marinovska <elm@umbraco.dk>
This commit is contained in:
@@ -10,6 +10,7 @@ using Semver;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Models.Packaging;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.BackOffice.Filters;
|
||||
using Umbraco.Web.Common.Attributes;
|
||||
@@ -27,16 +28,16 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IPackagingService _packagingService;
|
||||
private readonly IWebSecurity _webSecurity;
|
||||
private readonly IBackofficeSecurityAccessor _backofficeSecurityAccessor;
|
||||
|
||||
public PackageController(
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IPackagingService packagingService,
|
||||
IWebSecurity webSecurity)
|
||||
IBackofficeSecurityAccessor backofficeSecurityAccessor)
|
||||
{
|
||||
_hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
|
||||
_packagingService = packagingService ?? throw new ArgumentNullException(nameof(packagingService));
|
||||
_webSecurity = webSecurity ?? throw new ArgumentNullException(nameof(webSecurity));
|
||||
_backofficeSecurityAccessor = backofficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backofficeSecurityAccessor));
|
||||
}
|
||||
|
||||
public IEnumerable<PackageDefinition> GetCreatedPackages()
|
||||
@@ -90,7 +91,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
[HttpDelete]
|
||||
public IActionResult DeleteCreatedPackage(int packageId)
|
||||
{
|
||||
_packagingService.DeleteCreatedPackage(packageId, _webSecurity.GetUserId().ResultOr(0));
|
||||
_packagingService.DeleteCreatedPackage(packageId, _backofficeSecurityAccessor.BackofficeSecurity.GetUserId().ResultOr(0));
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user