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:
@@ -8,6 +8,7 @@ using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Mapping;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.BackOffice.Filters;
|
||||
using Umbraco.Web.Common.Attributes;
|
||||
@@ -34,7 +35,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILocalizationService _localizationService;
|
||||
private readonly IWebSecurity _webSecurity;
|
||||
private readonly IBackofficeSecurityAccessor _backofficeSecurityAccessor;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
private readonly ILocalizedTextService _localizedTextService;
|
||||
private readonly UmbracoMapper _umbracoMapper;
|
||||
@@ -42,7 +43,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
public DictionaryController(
|
||||
ILogger logger,
|
||||
ILocalizationService localizationService,
|
||||
IWebSecurity webSecurity,
|
||||
IBackofficeSecurityAccessor backofficeSecurityAccessor,
|
||||
IOptions<GlobalSettings> globalSettings,
|
||||
ILocalizedTextService localizedTextService,
|
||||
UmbracoMapper umbracoMapper
|
||||
@@ -50,7 +51,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_localizationService = localizationService ?? throw new ArgumentNullException(nameof(localizationService));
|
||||
_webSecurity = webSecurity ?? throw new ArgumentNullException(nameof(webSecurity));
|
||||
_backofficeSecurityAccessor = backofficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backofficeSecurityAccessor));
|
||||
_globalSettings = globalSettings.Value ?? throw new ArgumentNullException(nameof(globalSettings));
|
||||
_localizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService));
|
||||
_umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper));
|
||||
@@ -74,10 +75,10 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
|
||||
foreach (var dictionaryItem in foundDictionaryDescendants)
|
||||
{
|
||||
_localizationService.Delete(dictionaryItem, _webSecurity.CurrentUser.Id);
|
||||
_localizationService.Delete(dictionaryItem, _backofficeSecurityAccessor.BackofficeSecurity.CurrentUser.Id);
|
||||
}
|
||||
|
||||
_localizationService.Delete(foundDictionary, _webSecurity.CurrentUser.Id);
|
||||
_localizationService.Delete(foundDictionary, _backofficeSecurityAccessor.BackofficeSecurity.CurrentUser.Id);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
@@ -104,7 +105,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
var message = _localizedTextService.Localize(
|
||||
"dictionaryItem/changeKeyError",
|
||||
_webSecurity.CurrentUser.GetUserCulture(_localizedTextService, _globalSettings),
|
||||
_backofficeSecurityAccessor.BackofficeSecurity.CurrentUser.GetUserCulture(_localizedTextService, _globalSettings),
|
||||
new Dictionary<string, string> { { "0", key } });
|
||||
throw HttpResponseException.CreateNotificationValidationErrorResponse(message);
|
||||
}
|
||||
@@ -218,7 +219,7 @@ namespace Umbraco.Web.BackOffice.Controllers
|
||||
if (dictionaryItem == null)
|
||||
throw HttpResponseException.CreateNotificationValidationErrorResponse("Dictionary item does not exist");
|
||||
|
||||
var userCulture = _webSecurity.CurrentUser.GetUserCulture(_localizedTextService, _globalSettings);
|
||||
var userCulture = _backofficeSecurityAccessor.BackofficeSecurity.CurrentUser.GetUserCulture(_localizedTextService, _globalSettings);
|
||||
|
||||
if (dictionary.NameIsDirty)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user