diff --git a/src/Umbraco.Cms.Api.Management/Controllers/DataType/Folder/DataTypeFolderControllerBase.cs b/src/Umbraco.Cms.Api.Management/Controllers/DataType/Folder/DataTypeFolderControllerBase.cs index bb4e0703de..6e9e781fe7 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/DataType/Folder/DataTypeFolderControllerBase.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/DataType/Folder/DataTypeFolderControllerBase.cs @@ -32,14 +32,14 @@ public abstract class DataTypeFolderControllerBase : FolderManagementControllerB protected override async Task GetParentContainerAsync(EntityContainer container) => await _dataTypeContainerService.GetParentAsync(container); - protected override async Task> CreateContainerAsync(EntityContainer container, Guid? parentId, Guid userId) - => await _dataTypeContainerService.CreateAsync(container, parentId, userId); + protected override async Task> CreateContainerAsync(EntityContainer container, Guid? parentId, Guid userKey) + => await _dataTypeContainerService.CreateAsync(container, parentId, userKey); - protected override async Task> UpdateContainerAsync(EntityContainer container, Guid userId) - => await _dataTypeContainerService.UpdateAsync(container, userId); + protected override async Task> UpdateContainerAsync(EntityContainer container, Guid userKey) + => await _dataTypeContainerService.UpdateAsync(container, userKey); - protected override async Task> DeleteContainerAsync(Guid id, Guid userId) - => await _dataTypeContainerService.DeleteAsync(id, userId); + protected override async Task> DeleteContainerAsync(Guid id, Guid userKey) + => await _dataTypeContainerService.DeleteAsync(id, userKey); protected override IActionResult OperationStatusResult(DataTypeContainerOperationStatus status) => status switch diff --git a/src/Umbraco.Cms.Api.Management/Controllers/UserGroup/CreateUserGroupController.cs b/src/Umbraco.Cms.Api.Management/Controllers/UserGroup/CreateUserGroupController.cs index 140590f44d..1340c6c9c6 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/UserGroup/CreateUserGroupController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/UserGroup/CreateUserGroupController.cs @@ -49,7 +49,7 @@ public class CreateUserGroupController : UserGroupControllerBase IUserGroup group = userGroupCreationAttempt.Result; - Attempt result = await _userGroupService.CreateAsync(group, /*currentUser.Id*/ -1); + Attempt result = await _userGroupService.CreateAsync(group, CurrentUserKey(_backOfficeSecurityAccessor)); return result.Success ? CreatedAtAction(controller => nameof(controller.ByKey), group.Key) : UserGroupOperationStatusResult(result.Status); diff --git a/src/Umbraco.Cms.Api.Management/Controllers/UserGroup/UpdateUserGroupController.cs b/src/Umbraco.Cms.Api.Management/Controllers/UserGroup/UpdateUserGroupController.cs index e19dd29a98..8e3b6b9c28 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/UserGroup/UpdateUserGroupController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/UserGroup/UpdateUserGroupController.cs @@ -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 result = await _userGroupService.UpdateAsync(userGroup, -1); + Attempt result = await _userGroupService.UpdateAsync(userGroup, CurrentUserKey(_backOfficeSecurityAccessor)); return result.Success ? Ok() diff --git a/src/Umbraco.Core/Services/IPartialViewService.cs b/src/Umbraco.Core/Services/IPartialViewService.cs index b6c0a17758..567a4686af 100644 --- a/src/Umbraco.Core/Services/IPartialViewService.cs +++ b/src/Umbraco.Core/Services/IPartialViewService.cs @@ -11,9 +11,9 @@ public interface IPartialViewService : IBasicFileService /// Deletes a partial view. /// /// The path of the partial view to delete. - /// The key of the user performing the operation. + /// The key of the user performing the operation. /// An operation status. - Task DeleteAsync(string path, Guid performingUserKey); + Task DeleteAsync(string path, Guid userKey); /// /// Gets the name of all the available partial view snippets. @@ -34,15 +34,15 @@ public interface IPartialViewService : IBasicFileService /// Creates a new partial view. /// /// containing the information about the partial view being created. - /// The key of the user performing the operation. + /// The key of the user performing the operation. /// An attempt indicating if the operation was a success as well as a more detailed . - Task> CreateAsync(PartialViewCreateModel createModel, Guid performingUserKey); + Task> CreateAsync(PartialViewCreateModel createModel, Guid userKey); /// /// Updates an existing partial view. /// /// A with the changes. - /// The key of the user performing the operation. + /// The key of the user performing the operation. /// An attempt indicating if the operation was a success as well as a more detailed . - Task> UpdateAsync(PartialViewUpdateModel updateModel, Guid performingUserKey); + Task> UpdateAsync(PartialViewUpdateModel updateModel, Guid userKey); } diff --git a/src/Umbraco.Core/Services/IScriptService.cs b/src/Umbraco.Core/Services/IScriptService.cs index f6fbb277e3..24f5c8a86f 100644 --- a/src/Umbraco.Core/Services/IScriptService.cs +++ b/src/Umbraco.Core/Services/IScriptService.cs @@ -9,23 +9,23 @@ public interface IScriptService : IBasicFileService /// Creates a new script. /// /// containing the information about the script being created. - /// The key of the user performing the operation. + /// The key of the user performing the operation. /// An attempt indicating if the operation was a success as well as a more detailed . - Task> CreateAsync(ScriptCreateModel createModel, Guid performingUserKey); + Task> CreateAsync(ScriptCreateModel createModel, Guid userKey); /// /// Updates an existing script. /// /// A with the changes. - /// The key of the user performing the operation. + /// The key of the user performing the operation. /// An attempt indicating if the operation was a success as well as a more detailed . - Task> UpdateAsync(ScriptUpdateModel updateModel, Guid performingUserKey); + Task> UpdateAsync(ScriptUpdateModel updateModel, Guid userKey); /// /// Deletes a Script. /// /// The path of the script to delete. - /// The key of the user performing the operation. + /// The key of the user performing the operation. /// An operation status. - Task DeleteAsync(string path, Guid performingUserKey); + Task DeleteAsync(string path, Guid userKey); } diff --git a/src/Umbraco.Core/Services/IStylesheetService.cs b/src/Umbraco.Core/Services/IStylesheetService.cs index 974774058e..131c4d1ac3 100644 --- a/src/Umbraco.Core/Services/IStylesheetService.cs +++ b/src/Umbraco.Core/Services/IStylesheetService.cs @@ -9,23 +9,23 @@ public interface IStylesheetService : IBasicFileService /// Creates a new stylesheet. /// /// containing the information about the stylesheet being created. - /// The key of the user performing the operation. + /// The key of the user performing the operation. /// An attempt indicating if the operation was a success as well as a more detailed . - Task> CreateAsync(StylesheetCreateModel createModel, Guid performingUserKey); + Task> CreateAsync(StylesheetCreateModel createModel, Guid userKey); /// /// Updates an existing stylesheet. /// /// A with the changes. - /// The key of the user performing the operation. + /// The key of the user performing the operation. /// An attempt indicating if the operation was a success as well as a more detailed . - Task> UpdateAsync(StylesheetUpdateModel updateModel, Guid performingUserKey); + Task> UpdateAsync(StylesheetUpdateModel updateModel, Guid userKey); /// /// Deletes a stylesheet. /// /// The path of the stylesheet to delete. - /// The key of the user performing the operation. + /// The key of the user performing the operation. /// An operation status. - Task DeleteAsync(string path, Guid performingUserKey); + Task DeleteAsync(string path, Guid userKey); } diff --git a/src/Umbraco.Core/Services/IUserGroupService.cs b/src/Umbraco.Core/Services/IUserGroupService.cs index ab8251e9c3..364e70f394 100644 --- a/src/Umbraco.Core/Services/IUserGroupService.cs +++ b/src/Umbraco.Core/Services/IUserGroupService.cs @@ -66,18 +66,18 @@ public interface IUserGroupService /// Persists a new user group. /// /// The user group to create. - /// The ID of the user responsible for creating the group. - /// The IDs of the users that should be part of the group when created. + /// The key of the user responsible for creating the group. + /// The keys of the users that should be part of the group when created. /// An attempt indicating if the operation was a success as well as a more detailed . - Task> CreateAsync(IUserGroup userGroup, int performingUserId, int[]? groupMembersUserIds = null); + Task> CreateAsync(IUserGroup userGroup, Guid userKey, Guid[]? groupMembersKeys = null); /// /// Updates an existing user group. /// /// The user group to update. - /// The ID of the user responsible for updating the group. + /// The ID of the user responsible for updating the group. /// An attempt indicating if the operation was a success as well as a more detailed . - Task> UpdateAsync(IUserGroup userGroup, int performingUserId); + Task> UpdateAsync(IUserGroup userGroup, Guid userKey); /// /// Deletes a UserGroup diff --git a/src/Umbraco.Core/Services/IUserService.cs b/src/Umbraco.Core/Services/IUserService.cs index 8727af6aab..41cb6cae01 100644 --- a/src/Umbraco.Core/Services/IUserService.cs +++ b/src/Umbraco.Core/Services/IUserService.cs @@ -51,31 +51,31 @@ public interface IUserService : IMembershipUserService /// /// This creates both the Umbraco user and the identity user. /// - /// The key of the user performing the operation. + /// The key of the user performing the operation. /// Model to create the user from. /// Specifies if the user should be enabled be default. Defaults to false. /// An attempt indicating if the operation was a success as well as a more detailed . - Task> CreateAsync(Guid performingUserKey, UserCreateModel model, bool approveUser = false); + Task> CreateAsync(Guid userKey, UserCreateModel model, bool approveUser = false); - Task> InviteAsync(Guid performingUserKey, UserInviteModel model); + Task> InviteAsync(Guid userKey, UserInviteModel model); Task> VerifyInviteAsync(Guid userKey, string token); Task> CreateInitialPasswordAsync(Guid userKey, string token, string password); - - Task> UpdateAsync(Guid performingUserKey, UserUpdateModel model); + + Task> UpdateAsync(Guid userKey, UserUpdateModel model); Task SetAvatarAsync(Guid userKey, Guid temporaryFileKey); Task DeleteAsync(Guid key); - Task DisableAsync(Guid performingUserKey, ISet keys); + Task DisableAsync(Guid userKey, ISet keys); - Task EnableAsync(Guid performingUserKey, ISet keys); + Task EnableAsync(Guid userKey, ISet keys); - Task> UnlockAsync(Guid performingUserKey, params Guid[] keys); + Task> UnlockAsync(Guid userKey, params Guid[] keys); - Task> ChangePasswordAsync(Guid performingUserKey, ChangeUserPasswordModel model); + Task> ChangePasswordAsync(Guid userKey, ChangeUserPasswordModel model); Task ClearAvatarAsync(Guid userKey); @@ -84,12 +84,14 @@ public interface IUserService : IMembershipUserService /// /// Gets all users that the requesting user is allowed to see. /// - /// The Key of the user requesting the users. - /// - Task?, UserOperationStatus>> GetAllAsync(Guid requestingUserKey, int skip, int take) => throw new NotImplementedException(); + /// The Key of the user requesting the users. + /// Amount to skip. + /// Amount to take. + /// All users that the user is allowed to see. + Task?, UserOperationStatus>> GetAllAsync(Guid userKey, int skip, int take) => throw new NotImplementedException(); public Task, UserOperationStatus>> FilterAsync( - Guid requestingUserKey, + Guid userKey, UserFilter filter, int skip = 0, int take = 100, diff --git a/src/Umbraco.Core/Services/PartialViewService.cs b/src/Umbraco.Core/Services/PartialViewService.cs index b69ac149c8..99b111021c 100644 --- a/src/Umbraco.Core/Services/PartialViewService.cs +++ b/src/Umbraco.Core/Services/PartialViewService.cs @@ -37,7 +37,7 @@ public class PartialViewService : FileServiceBase - public async Task DeleteAsync(string path, Guid performingUserKey) + public async Task DeleteAsync(string path, Guid userKey) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); @@ -60,7 +60,7 @@ public class PartialViewService : FileServiceBase - public async Task> CreateAsync(PartialViewCreateModel createModel, Guid performingUserKey) + public async Task> CreateAsync(PartialViewCreateModel createModel, Guid userKey) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); @@ -129,7 +129,7 @@ public class PartialViewService : FileServiceBase(PartialViewOperationStatus.Success, partialView); @@ -162,7 +162,7 @@ public class PartialViewService : FileServiceBase - public async Task> UpdateAsync(PartialViewUpdateModel updateModel, Guid performingUserKey) + public async Task> UpdateAsync(PartialViewUpdateModel updateModel, Guid userKey) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); IPartialView? partialView = Repository.Get(updateModel.ExistingPath); @@ -195,7 +195,7 @@ public class PartialViewService : FileServiceBase(PartialViewOperationStatus.Success, partialView); @@ -216,9 +216,9 @@ public class PartialViewService : FileServiceBase, IScrip } /// - public async Task DeleteAsync(string path, Guid performingUserKey) + public async Task DeleteAsync(string path, Guid userKey) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); @@ -55,14 +55,14 @@ public class ScriptService : FileServiceBase, IScrip scope.Notifications.Publish( new ScriptDeletedNotification(script, eventMessages).WithStateFrom(deletingNotification)); - await AuditAsync(AuditType.Delete, performingUserKey); + await AuditAsync(AuditType.Delete, userKey); scope.Complete(); return ScriptOperationStatus.Success; } /// - public async Task> CreateAsync(ScriptCreateModel createModel, Guid performingUserKey) + public async Task> CreateAsync(ScriptCreateModel createModel, Guid userKey) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); @@ -92,7 +92,7 @@ public class ScriptService : FileServiceBase, IScrip Repository.Save(script); scope.Notifications.Publish(new ScriptSavedNotification(script, eventMessages).WithStateFrom(savingNotification)); - await AuditAsync(AuditType.Save, performingUserKey); + await AuditAsync(AuditType.Save, userKey); scope.Complete(); return Attempt.SucceedWithStatus(ScriptOperationStatus.Success, script); @@ -125,7 +125,7 @@ public class ScriptService : FileServiceBase, IScrip } /// - public async Task> UpdateAsync(ScriptUpdateModel updateModel, Guid performingUserKey) + public async Task> UpdateAsync(ScriptUpdateModel updateModel, Guid userKey) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); IScript? script = Repository.Get(updateModel.ExistingPath); @@ -159,7 +159,7 @@ public class ScriptService : FileServiceBase, IScrip Repository.Save(script); scope.Notifications.Publish(new ScriptSavedNotification(script, eventMessages).WithStateFrom(savingNotification)); - await AuditAsync(AuditType.Save, performingUserKey); + await AuditAsync(AuditType.Save, userKey); scope.Complete(); return Attempt.SucceedWithStatus(ScriptOperationStatus.Success, script); @@ -180,9 +180,9 @@ public class ScriptService : FileServiceBase, IScrip return ScriptOperationStatus.Success; } - private async Task AuditAsync(AuditType type, Guid performingUserKey) + private async Task AuditAsync(AuditType type, Guid userKey) { - int userId = await _userIdKeyResolver.GetAsync(performingUserKey); + int userId = await _userIdKeyResolver.GetAsync(userKey); _auditRepository.Save(new AuditItem(-1, type, userId, "Script")); } } diff --git a/src/Umbraco.Core/Services/StylesheetService.cs b/src/Umbraco.Core/Services/StylesheetService.cs index a25a35e696..537aecad9d 100644 --- a/src/Umbraco.Core/Services/StylesheetService.cs +++ b/src/Umbraco.Core/Services/StylesheetService.cs @@ -32,7 +32,7 @@ public class StylesheetService : FileServiceBase - public async Task DeleteAsync(string path, Guid performingUserKey) + public async Task DeleteAsync(string path, Guid userKey) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); @@ -52,14 +52,14 @@ public class StylesheetService : FileServiceBase - public async Task> CreateAsync(StylesheetCreateModel createModel, Guid performingUserKey) + public async Task> CreateAsync(StylesheetCreateModel createModel, Guid userKey) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); @@ -89,7 +89,7 @@ public class StylesheetService : FileServiceBase(StylesheetOperationStatus.Success, stylesheet); @@ -122,7 +122,7 @@ public class StylesheetService : FileServiceBase - public async Task> UpdateAsync(StylesheetUpdateModel updateModel, Guid performingUserKey) + public async Task> UpdateAsync(StylesheetUpdateModel updateModel, Guid userKey) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); @@ -157,7 +157,7 @@ public class StylesheetService : FileServiceBase(StylesheetOperationStatus.Success, stylesheet); @@ -178,9 +178,9 @@ public class StylesheetService : FileServiceBase public async Task> CreateAsync( IUserGroup userGroup, - int performingUserId, - int[]? groupMembersUserIds = null) + Guid userKey, + Guid[]? groupMembersKeys = null) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); - IUser? performingUser = _userService.GetUserById(performingUserId); + IUser? performingUser = await _userService.GetAsync(userKey); if (performingUser is null) { return Attempt.FailWithStatus(UserGroupOperationStatus.MissingUser, userGroup); @@ -238,12 +238,12 @@ internal sealed class UserGroupService : RepositoryService, IUserGroupService return Attempt.FailWithStatus(UserGroupOperationStatus.CancelledByNotification, userGroup); } - var checkedGroupMembers = EnsureNonAdminUserIsInSavedUserGroup(performingUser, groupMembersUserIds ?? Enumerable.Empty()).ToArray(); - IEnumerable usersToAdd = _userService.GetUsersById(performingUserId); + Guid[] checkedGroupMembersKeys = EnsureNonAdminUserIsInSavedUserGroup(performingUser, groupMembersKeys ?? Enumerable.Empty()).ToArray(); + IUser[] usersToAdd = (await _userService.GetAsync(checkedGroupMembersKeys)).ToArray(); // Since this is a brand new creation we don't have to be worried about what users were added and removed // simply put all members that are requested to be in the group will be "added" - var userGroupWithUsers = new UserGroupWithUsers(userGroup, usersToAdd.ToArray(), Array.Empty()); + var userGroupWithUsers = new UserGroupWithUsers(userGroup, usersToAdd, Array.Empty()); var savingUserGroupWithUsersNotification = new UserGroupWithUsersSavingNotification(userGroupWithUsers, eventMessages); if (await scope.Notifications.PublishCancelableAsync(savingUserGroupWithUsersNotification)) { @@ -251,7 +251,7 @@ internal sealed class UserGroupService : RepositoryService, IUserGroupService return Attempt.FailWithStatus(UserGroupOperationStatus.CancelledByNotification, userGroup); } - _userGroupRepository.AddOrUpdateGroupWithUsers(userGroup, checkedGroupMembers); + _userGroupRepository.AddOrUpdateGroupWithUsers(userGroup, usersToAdd.Select(x => x.Id).ToArray()); scope.Complete(); return Attempt.SucceedWithStatus(UserGroupOperationStatus.Success, userGroup); @@ -281,11 +281,11 @@ internal sealed class UserGroupService : RepositoryService, IUserGroupService /// public async Task> UpdateAsync( IUserGroup userGroup, - int performingUserId) + Guid userKey) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); - IUser? performingUser = _userService.GetUserById(performingUserId); + IUser? performingUser = await _userService.GetAsync(userKey); if (performingUser is null) { return Attempt.FailWithStatus(UserGroupOperationStatus.MissingUser, userGroup); @@ -402,16 +402,16 @@ internal sealed class UserGroupService : RepositoryService, IUserGroupService /// /// This is to ensure that the user can access the group they themselves created at a later point and modify it. /// - private IEnumerable EnsureNonAdminUserIsInSavedUserGroup(IUser performingUser, IEnumerable groupMembersUserIds) + private IEnumerable EnsureNonAdminUserIsInSavedUserGroup(IUser performingUser, IEnumerable groupMembersUserKeys) { - var userIds = groupMembersUserIds.ToList(); + var userKeys = groupMembersUserKeys.ToList(); - // If the performing user is and admin we don't care, they can access the group later regardless - if (performingUser.IsAdmin() is false && userIds.Contains(performingUser.Id) is false) + // If the performing user is an admin we don't care, they can access the group later regardless + if (performingUser.IsAdmin() is false && userKeys.Contains(performingUser.Key) is false) { - userIds.Add(performingUser.Id); + userKeys.Add(performingUser.Key); } - return userIds; + return userKeys; } } diff --git a/src/Umbraco.Core/Services/UserService.cs b/src/Umbraco.Core/Services/UserService.cs index 0c0db6c9c9..c82d1deb02 100644 --- a/src/Umbraco.Core/Services/UserService.cs +++ b/src/Umbraco.Core/Services/UserService.cs @@ -599,12 +599,12 @@ internal class UserService : RepositoryService, IUserService } /// - public async Task> CreateAsync(Guid performingUserKey, UserCreateModel model, bool approveUser = false) + public async Task> CreateAsync(Guid userKey, UserCreateModel model, bool approveUser = false) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); using IServiceScope serviceScope = _serviceScopeFactory.CreateScope(); - IUser? performingUser = await GetAsync(performingUserKey); + IUser? performingUser = await GetAsync(userKey); if (performingUser is null) { @@ -680,12 +680,12 @@ internal class UserService : RepositoryService, IUserService return Attempt.SucceedWithStatus(UserOperationStatus.Success, creationResult); } - public async Task> InviteAsync(Guid performingUserKey, UserInviteModel model) + public async Task> InviteAsync(Guid userKey, UserInviteModel model) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); using IServiceScope serviceScope = _serviceScopeFactory.CreateScope(); - IUser? performingUser = await GetAsync(performingUserKey); + IUser? performingUser = await GetAsync(userKey); if (performingUser is null) { @@ -803,7 +803,7 @@ internal class UserService : RepositoryService, IUserService return UserOperationStatus.Success; } - public async Task> UpdateAsync(Guid performingUserKey, UserUpdateModel model) + public async Task> UpdateAsync(Guid userKey, UserUpdateModel model) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); using IServiceScope serviceScope = _serviceScopeFactory.CreateScope(); @@ -816,7 +816,7 @@ internal class UserService : RepositoryService, IUserService return Attempt.FailWithStatus(UserOperationStatus.MissingUser, existingUser); } - IUser? performingUser = await userStore.GetAsync(performingUserKey); + IUser? performingUser = await userStore.GetAsync(userKey); if (performingUser is null) { @@ -1007,7 +1007,7 @@ internal class UserService : RepositoryService, IUserService return keys; } - public async Task> ChangePasswordAsync(Guid performingUserKey, ChangeUserPasswordModel model) + public async Task> ChangePasswordAsync(Guid userKey, ChangeUserPasswordModel model) { IServiceScope serviceScope = _serviceScopeFactory.CreateScope(); using ICoreScope scope = ScopeProvider.CreateCoreScope(); @@ -1019,7 +1019,7 @@ internal class UserService : RepositoryService, IUserService return Attempt.FailWithStatus(UserOperationStatus.UserNotFound, new PasswordChangedModel()); } - IUser? performingUser = await userStore.GetAsync(performingUserKey); + IUser? performingUser = await userStore.GetAsync(userKey); if (performingUser is null) { return Attempt.FailWithStatus(UserOperationStatus.MissingUser, new PasswordChangedModel()); @@ -1052,11 +1052,11 @@ internal class UserService : RepositoryService, IUserService return Attempt.SucceedWithStatus(UserOperationStatus.Success, result.Result ?? new PasswordChangedModel()); } - public async Task?, UserOperationStatus>> GetAllAsync(Guid requestingUserKey, int skip, int take) + public async Task?, UserOperationStatus>> GetAllAsync(Guid userKey, int skip, int take) { using ICoreScope scope = ScopeProvider.CreateCoreScope(); - IUser? requestingUser = await GetAsync(requestingUserKey); + IUser? requestingUser = await GetAsync(userKey); if (requestingUser is null) { @@ -1099,7 +1099,7 @@ internal class UserService : RepositoryService, IUserService } public async Task, UserOperationStatus>> FilterAsync( - Guid requestingUserKey, + Guid userKey, UserFilter filter, int skip = 0, int take = 100, @@ -1108,7 +1108,7 @@ internal class UserService : RepositoryService, IUserService { using ICoreScope scope = ScopeProvider.CreateCoreScope(); - IUser? requestingUser = await GetAsync(requestingUserKey); + IUser? requestingUser = await GetAsync(userKey); if (requestingUser is null) { @@ -1292,7 +1292,7 @@ internal class UserService : RepositoryService, IUserService return UserOperationStatus.Success; } - public async Task DisableAsync(Guid performingUserKey, ISet keys) + public async Task DisableAsync(Guid userKey, ISet keys) { if(keys.Any() is false) { @@ -1300,7 +1300,7 @@ internal class UserService : RepositoryService, IUserService } using ICoreScope scope = ScopeProvider.CreateCoreScope(); - IUser? performingUser = await GetAsync(performingUserKey); + IUser? performingUser = await GetAsync(userKey); if (performingUser is null) { @@ -1338,7 +1338,7 @@ internal class UserService : RepositoryService, IUserService return UserOperationStatus.Success; } - public async Task EnableAsync(Guid performingUserKey, ISet keys) + public async Task EnableAsync(Guid userKey, ISet keys) { if(keys.Any() is false) { @@ -1346,7 +1346,7 @@ internal class UserService : RepositoryService, IUserService } using ICoreScope scope = ScopeProvider.CreateCoreScope(); - IUser? performingUser = await GetAsync(performingUserKey); + IUser? performingUser = await GetAsync(userKey); if (performingUser is null) { @@ -1408,7 +1408,7 @@ internal class UserService : RepositoryService, IUserService return UserOperationStatus.Success; } - public async Task> UnlockAsync(Guid performingUserKey, params Guid[] keys) + public async Task> UnlockAsync(Guid userKey, params Guid[] keys) { if (keys.Length == 0) { @@ -1416,7 +1416,7 @@ internal class UserService : RepositoryService, IUserService } using ICoreScope scope = ScopeProvider.CreateCoreScope(); - IUser? performingUser = await GetAsync(performingUserKey); + IUser? performingUser = await GetAsync(userKey); if (performingUser is null) { diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Core/Services/UserGroupServiceValidationTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Core/Services/UserGroupServiceValidationTests.cs index e52a342305..16518a6c03 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Core/Services/UserGroupServiceValidationTests.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Core/Services/UserGroupServiceValidationTests.cs @@ -25,7 +25,7 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest Name = null }; - var result = await UserGroupService.CreateAsync(userGroup, Constants.Security.SuperUserId); + var result = await UserGroupService.CreateAsync(userGroup, Constants.Security.SuperUserKey); Assert.IsFalse(result.Success); Assert.AreEqual(UserGroupOperationStatus.MissingName, result.Status); @@ -39,7 +39,7 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest Name = "Sed porttitor lectus nibh. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Vivamus suscipit tortor eget felis porttitor volutpat. Quisque velit nisi, pretium ut lacinia in, elementum id enim." }; - var result = await UserGroupService.CreateAsync(userGroup, Constants.Security.SuperUserId); + var result = await UserGroupService.CreateAsync(userGroup, Constants.Security.SuperUserKey); Assert.IsFalse(result.Success); Assert.AreEqual(UserGroupOperationStatus.NameTooLong, result.Status); @@ -54,7 +54,7 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest Alias = "Sed porttitor lectus nibh. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Vivamus suscipit tortor eget felis porttitor volutpat. Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus suscipit tortor eget felis porttitor volutpat. Quisque velit nisi, pretium ut lacinia in, elementum id enim." }; - var result = await UserGroupService.CreateAsync(userGroup, Constants.Security.SuperUserId); + var result = await UserGroupService.CreateAsync(userGroup, Constants.Security.SuperUserKey); Assert.IsFalse(result.Success); Assert.AreEqual(UserGroupOperationStatus.AliasTooLong, result.Status); @@ -69,7 +69,7 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest Alias = "someAlias" }; - var result = await UserGroupService.UpdateAsync(userGroup, Constants.Security.SuperUserId); + var result = await UserGroupService.UpdateAsync(userGroup, Constants.Security.SuperUserKey); Assert.IsFalse(result.Success); Assert.AreEqual(UserGroupOperationStatus.NotFound, result.Status); @@ -84,11 +84,11 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest Alias = "someAlias" }; - var result = await UserGroupService.CreateAsync(userGroup, Constants.Security.SuperUserId); + var result = await UserGroupService.CreateAsync(userGroup, Constants.Security.SuperUserKey); Assert.IsTrue(result.Success); - result = await UserGroupService.CreateAsync(userGroup, Constants.Security.SuperUserId); + result = await UserGroupService.CreateAsync(userGroup, Constants.Security.SuperUserKey); Assert.IsFalse(result.Success); Assert.AreEqual(UserGroupOperationStatus.AlreadyExists, result.Status); @@ -104,7 +104,7 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest Name = "I already exist", Alias = alias }; - var setupResult = await UserGroupService.CreateAsync(existingUserGroup, Constants.Security.SuperUserId); + var setupResult = await UserGroupService.CreateAsync(existingUserGroup, Constants.Security.SuperUserKey); Assert.IsTrue(setupResult.Success); var newUserGroup = new UserGroup(ShortStringHelper) @@ -112,7 +112,7 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest Name = "I have a duplicate alias", Alias = alias, }; - var result = await UserGroupService.CreateAsync(newUserGroup, Constants.Security.SuperUserId); + var result = await UserGroupService.CreateAsync(newUserGroup, Constants.Security.SuperUserKey); Assert.IsFalse(result.Success); Assert.AreEqual(UserGroupOperationStatus.DuplicateAlias, result.Status); @@ -128,7 +128,7 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest Name = "I already exist", Alias = alias }; - var setupResult = await UserGroupService.CreateAsync(existingUserGroup, Constants.Security.SuperUserId); + var setupResult = await UserGroupService.CreateAsync(existingUserGroup, Constants.Security.SuperUserKey); Assert.IsTrue(setupResult.Success); IUserGroup userGroupToUpdate = new UserGroup(ShortStringHelper) @@ -136,7 +136,7 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest Name = "I don't have a duplicate alias", Alias = "somAlias", }; - var creationResult = await UserGroupService.CreateAsync(userGroupToUpdate, Constants.Security.SuperUserId); + var creationResult = await UserGroupService.CreateAsync(userGroupToUpdate, Constants.Security.SuperUserKey); Assert.IsTrue(creationResult.Success); @@ -144,7 +144,7 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest userGroupToUpdate.Name = "Now I have a duplicate alias"; userGroupToUpdate.Alias = alias; - var updateResult = await UserGroupService.UpdateAsync(userGroupToUpdate, Constants.Security.SuperUserId); + var updateResult = await UserGroupService.UpdateAsync(userGroupToUpdate, Constants.Security.SuperUserKey); Assert.IsFalse(updateResult.Success); Assert.AreEqual(UserGroupOperationStatus.DuplicateAlias, updateResult.Status); } @@ -157,13 +157,13 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest Name = "Some Name", Alias = "someAlias" }; - var setupResult = await UserGroupService.CreateAsync(userGroup, Constants.Security.SuperUserId); + var setupResult = await UserGroupService.CreateAsync(userGroup, Constants.Security.SuperUserKey); Assert.IsTrue(setupResult.Success); var updateName = "New Name"; userGroup.Name = updateName; - var updateResult = await UserGroupService.UpdateAsync(userGroup, Constants.Security.SuperUserId); + var updateResult = await UserGroupService.UpdateAsync(userGroup, Constants.Security.SuperUserKey); Assert.IsTrue(updateResult.Success); var updatedGroup = updateResult.Result; Assert.AreEqual(updateName, updatedGroup.Name);