示例#1
0
        public async Task <MemberRole> GetMemberRoleAsync(Guid adminUserId, Guid targetUserId, CancellationToken cancellationToken)
        {
            if (Guid.Empty == adminUserId)
            {
                throw new ArgumentOutOfRangeException(nameof(adminUserId));
            }
            if (Guid.Empty == targetUserId)
            {
                throw new ArgumentOutOfRangeException(nameof(targetUserId));
            }

            var userCanPerformAction = await _permissionsService.UserCanPerformActionAsync(adminUserId, EditMembersRole, cancellationToken);

            if (!userCanPerformAction)
            {
                _logger.LogError($"Error: GetMemberRoleAsync - User:{0} does not have access to view the members role", adminUserId);
                throw new SecurityException($"Error: User does not have access");
            }

            return(await _userCommand.GetMembershipUsersInRoleAsync(targetUserId, cancellationToken));
        }