V14: Consistently refer to user key (#14685)

* Fixup UserService

* Fixup PartialViewService

* Fixup ScriptService

* Fixup StylesheetService

* Use keys with usergroups instead of IDs

* Fix missed instances of performingUser

* Fixup DataTypeFolderControllerBase

---------

Co-authored-by: kjac <kja@umbraco.dk>
This commit is contained in:
Mole
2023-08-17 08:35:48 +02:00
committed by GitHub
parent fb3ead87b8
commit a1f6531453
14 changed files with 121 additions and 115 deletions

View File

@@ -32,14 +32,14 @@ public abstract class DataTypeFolderControllerBase : FolderManagementControllerB
protected override async Task<EntityContainer?> GetParentContainerAsync(EntityContainer container)
=> await _dataTypeContainerService.GetParentAsync(container);
protected override async Task<Attempt<EntityContainer, DataTypeContainerOperationStatus>> CreateContainerAsync(EntityContainer container, Guid? parentId, Guid userId)
=> await _dataTypeContainerService.CreateAsync(container, parentId, userId);
protected override async Task<Attempt<EntityContainer, DataTypeContainerOperationStatus>> CreateContainerAsync(EntityContainer container, Guid? parentId, Guid userKey)
=> await _dataTypeContainerService.CreateAsync(container, parentId, userKey);
protected override async Task<Attempt<EntityContainer, DataTypeContainerOperationStatus>> UpdateContainerAsync(EntityContainer container, Guid userId)
=> await _dataTypeContainerService.UpdateAsync(container, userId);
protected override async Task<Attempt<EntityContainer, DataTypeContainerOperationStatus>> UpdateContainerAsync(EntityContainer container, Guid userKey)
=> await _dataTypeContainerService.UpdateAsync(container, userKey);
protected override async Task<Attempt<EntityContainer?, DataTypeContainerOperationStatus>> DeleteContainerAsync(Guid id, Guid userId)
=> await _dataTypeContainerService.DeleteAsync(id, userId);
protected override async Task<Attempt<EntityContainer?, DataTypeContainerOperationStatus>> DeleteContainerAsync(Guid id, Guid userKey)
=> await _dataTypeContainerService.DeleteAsync(id, userKey);
protected override IActionResult OperationStatusResult(DataTypeContainerOperationStatus status)
=> status switch

View File

@@ -49,7 +49,7 @@ public class CreateUserGroupController : UserGroupControllerBase
IUserGroup group = userGroupCreationAttempt.Result;
Attempt<IUserGroup, UserGroupOperationStatus> result = await _userGroupService.CreateAsync(group, /*currentUser.Id*/ -1);
Attempt<IUserGroup, UserGroupOperationStatus> result = await _userGroupService.CreateAsync(group, CurrentUserKey(_backOfficeSecurityAccessor));
return result.Success
? CreatedAtAction<ByKeyUserGroupController>(controller => nameof(controller.ByKey), group.Key)
: UserGroupOperationStatusResult(result.Status);

View File

@@ -5,6 +5,7 @@ using Umbraco.Cms.Api.Management.Factories;
using Umbraco.Cms.Api.Management.ViewModels.UserGroup;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models.Membership;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Services.OperationStatus;
@@ -15,13 +16,16 @@ public class UpdateUserGroupController : UserGroupControllerBase
{
private readonly IUserGroupService _userGroupService;
private readonly IUserGroupPresentationFactory _userGroupPresentationFactory;
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
public UpdateUserGroupController(
IUserGroupService userGroupService,
IUserGroupPresentationFactory userGroupPresentationFactory)
IUserGroupPresentationFactory userGroupPresentationFactory,
IBackOfficeSecurityAccessor backOfficeSecurityAccessor)
{
_userGroupService = userGroupService;
_userGroupPresentationFactory = userGroupPresentationFactory;
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
}
[HttpPut("{id:guid}")]
@@ -44,7 +48,7 @@ public class UpdateUserGroupController : UserGroupControllerBase
}
IUserGroup userGroup = userGroupUpdateAttempt.Result;
Attempt<IUserGroup, UserGroupOperationStatus> result = await _userGroupService.UpdateAsync(userGroup, -1);
Attempt<IUserGroup, UserGroupOperationStatus> result = await _userGroupService.UpdateAsync(userGroup, CurrentUserKey(_backOfficeSecurityAccessor));
return result.Success
? Ok()