@@ -170,8 +187,35 @@
private bool _loading;
private string? _error;
+ private UserKey? _loadedUserKey;
+
+ protected override async Task OnParametersSetAsync()
+ {
+ await base.OnParametersSetAsync();
+
+ var userKey = AuthState?.Identity?.UserKey;
+
+ if (userKey is null)
+ {
+ _loadedUserKey = null;
+ _events.Clear();
+ _error = null;
+ return;
+ }
+
+ if (_loadedUserKey == userKey)
+ return;
+
+ _loadedUserKey = userKey;
+
+ await InitializeActivityAsync(userKey.Value);
+ }
+
private async Task InitializeActivityAsync(UserKey currentUserKey)
{
+ _events.Clear();
+ _error = null;
+
var sandbox = await SandboxService.GetByUserAsync(currentUserKey);
if (sandbox is null)
@@ -205,6 +249,8 @@
}
catch (Exception)
{
+ _events.Clear();
+ _loadedUserKey = null;
_error = "Unable to load activity records.";
}
finally
@@ -213,6 +259,16 @@
}
}
+ private async Task RefreshActivityAsync()
+ {
+ var userKey = AuthState?.Identity?.UserKey;
+
+ if (userKey is null)
+ return;
+
+ await InitializeActivityAsync(userKey.Value);
+ }
+
private IEnumerable
FilteredEvents =>
_events
.Where(x =>
diff --git a/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Components/Pages/Dashboard/UsersPage.razor b/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Components/Pages/Dashboard/UsersPage.razor
index 6af62350..c07ff9fd 100644
--- a/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Components/Pages/Dashboard/UsersPage.razor
+++ b/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Components/Pages/Dashboard/UsersPage.razor
@@ -7,6 +7,7 @@
@layout DashboardLayout
@inject SandboxUserService SandboxUserService
@inject IDialogService DialogService
+@inject ISnackbar Snackbar
@attribute [UAuthAuthorize(Roles = "Ladmin,Owner")]
@@ -179,7 +180,14 @@
Size="Size.Small"
Disabled="@context.IsOwner"
OnClick="@(() => OpenUserDetailsAsync(context))" />
+
+
+
@@ -368,4 +376,49 @@
return await SandboxUserService.CreateAsync(actorUserKey.Value, request);
}
+
+ private async Task DeleteUserAsync(SandboxUserItem user)
+ {
+ if (user.IsOwner)
+ return;
+
+ var confirmed = await DialogService.ShowMessageBoxAsync(
+ "Permanently delete user?",
+ $"Delete {user.Username} permanently? This action cannot be undone.",
+ yesText: "Delete permanently",
+ cancelText: "Cancel");
+
+ if (confirmed != true)
+ return;
+
+ var actorUserKey = AuthState?.Identity?.UserKey;
+
+ if (actorUserKey is null)
+ return;
+
+ _loading = true;
+ _error = null;
+
+ try
+ {
+ var result = await SandboxUserService.DeleteAsync(actorUserKey.Value, user.UserKey);
+
+ if (!result.Success)
+ {
+ Snackbar.Add("Unable to delete user. Check server logs.", Severity.Error);
+ _error = result.Message;
+ return;
+ }
+
+ await LoadUsersAsync(actorUserKey.Value);
+ }
+ catch (Exception)
+ {
+ Snackbar.Add("Unable to delete user. Check server logs.", Severity.Error);
+ }
+ finally
+ {
+ _loading = false;
+ }
+ }
}
diff --git a/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Components/Pages/DashboardPage.razor b/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Components/Pages/DashboardPage.razor
index fff8c308..8b4c155a 100644
--- a/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Components/Pages/DashboardPage.razor
+++ b/apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/Components/Pages/DashboardPage.razor
@@ -9,6 +9,8 @@
@attribute [UAuthAuthorize(Roles = "Ladmin,Owner,User")]
@inject LabDashboardService DashboardService
+@inject LabOwnerRepairService OwnerRepairService
+@inject LabAccessContextProvider ContextProvider
@inject ISnackbar Snackbar