fix(07): fix people picker selection and audit service authentication
People picker ListBox used MouseBinding which fires before SelectedItem updates, causing null CommandParameter. Replaced with SelectionChanged event handler in code-behind. AuditUsersAsync created TenantProfile with empty ClientId, causing ArgumentException in SessionManager. Added currentProfile parameter to pass the authenticated tenant's ClientId through. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,7 @@ public interface IUserAccessAuditService
|
||||
/// <returns>Flat list of access entries for the target users.</returns>
|
||||
Task<IReadOnlyList<UserAccessEntry>> AuditUsersAsync(
|
||||
ISessionManager sessionManager,
|
||||
TenantProfile currentProfile,
|
||||
IReadOnlyList<string> targetUserLogins,
|
||||
IReadOnlyList<SiteInfo> sites,
|
||||
ScanOptions options,
|
||||
|
||||
@@ -24,6 +24,7 @@ public class UserAccessAuditService : IUserAccessAuditService
|
||||
|
||||
public async Task<IReadOnlyList<UserAccessEntry>> AuditUsersAsync(
|
||||
ISessionManager sessionManager,
|
||||
TenantProfile currentProfile,
|
||||
IReadOnlyList<string> targetUserLogins,
|
||||
IReadOnlyList<SiteInfo> sites,
|
||||
ScanOptions options,
|
||||
@@ -53,7 +54,7 @@ public class UserAccessAuditService : IUserAccessAuditService
|
||||
var profile = new TenantProfile
|
||||
{
|
||||
TenantUrl = site.Url,
|
||||
ClientId = string.Empty, // Will be set by SessionManager from cached session
|
||||
ClientId = currentProfile.ClientId,
|
||||
Name = site.Title
|
||||
};
|
||||
|
||||
|
||||
@@ -229,8 +229,15 @@ public partial class UserAccessAuditViewModel : FeatureViewModelBase
|
||||
FolderDepth: 1,
|
||||
IncludeSubsites: IncludeSubsites);
|
||||
|
||||
if (_currentProfile == null)
|
||||
{
|
||||
StatusMessage = "No tenant profile selected. Please connect first.";
|
||||
return;
|
||||
}
|
||||
|
||||
var entries = await _auditService.AuditUsersAsync(
|
||||
_sessionManager,
|
||||
_currentProfile,
|
||||
userLogins,
|
||||
effectiveSites,
|
||||
scanOptions,
|
||||
|
||||
@@ -31,8 +31,10 @@
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
<ListBox ItemsSource="{Binding SearchResults}" MaxHeight="120"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto" Margin="0,0,0,4">
|
||||
<ListBox x:Name="SearchResultsListBox"
|
||||
ItemsSource="{Binding SearchResults}" MaxHeight="120"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto" Margin="0,0,0,4"
|
||||
SelectionChanged="SearchResultsListBox_SelectionChanged">
|
||||
<ListBox.Style>
|
||||
<Style TargetType="ListBox">
|
||||
<Style.Triggers>
|
||||
@@ -54,11 +56,6 @@
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
<ListBox.InputBindings>
|
||||
<MouseBinding MouseAction="LeftClick"
|
||||
Command="{Binding AddUserCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ListBox}, Path=SelectedItem}" />
|
||||
</ListBox.InputBindings>
|
||||
</ListBox>
|
||||
<ItemsControl ItemsSource="{Binding SelectedUsers}" Margin="0,0,0,4">
|
||||
<ItemsControl.ItemTemplate>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Windows.Controls;
|
||||
using SharepointToolbox.Services;
|
||||
using SharepointToolbox.ViewModels.Tabs;
|
||||
|
||||
namespace SharepointToolbox.Views.Tabs;
|
||||
@@ -10,4 +11,17 @@ public partial class UserAccessAuditView : UserControl
|
||||
InitializeComponent();
|
||||
DataContext = viewModel;
|
||||
}
|
||||
|
||||
private void SearchResultsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (sender is ListBox listBox && listBox.SelectedItem is GraphUserResult user)
|
||||
{
|
||||
var vm = (UserAccessAuditViewModel)DataContext;
|
||||
if (vm.AddUserCommand.CanExecute(user))
|
||||
vm.AddUserCommand.Execute(user);
|
||||
|
||||
// Clear selection so the same item can be re-selected if needed
|
||||
listBox.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user