Replace hardcoded "system" user with actual logged-in user across all UI pages
All 22 occurrences of hardcoded "system" user string replaced with GetCurrentUserAsync() which reads the Username claim from AuthenticationState. Affected: Instances.razor (6), Sites.razor (2), Templates.razor (11), SharedScripts.razor (3).
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
@attribute [Authorize(Policy = AuthorizationPolicies.RequireAdmin)]
|
||||
@inject ISiteRepository SiteRepository
|
||||
@inject ArtifactDeploymentService ArtifactDeploymentService
|
||||
@inject AuthenticationStateProvider AuthStateProvider
|
||||
|
||||
<div class="container-fluid mt-3">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
@@ -126,6 +127,12 @@
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private async Task<string> GetCurrentUserAsync()
|
||||
{
|
||||
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
|
||||
return authState.User.FindFirst("Username")?.Value ?? "unknown";
|
||||
}
|
||||
|
||||
private List<Site> _sites = new();
|
||||
private Dictionary<int, List<DataConnection>> _siteConnections = new();
|
||||
private bool _loading = true;
|
||||
@@ -270,8 +277,9 @@
|
||||
try
|
||||
{
|
||||
var command = await ArtifactDeploymentService.BuildDeployArtifactsCommandAsync();
|
||||
var user = await GetCurrentUserAsync();
|
||||
var result = await ArtifactDeploymentService.RetryForSiteAsync(
|
||||
site.SiteIdentifier, command, "system");
|
||||
site.SiteIdentifier, command, user);
|
||||
|
||||
if (result.IsSuccess)
|
||||
_toast.ShowSuccess($"Artifacts deployed to '{site.Name}'.");
|
||||
@@ -294,7 +302,8 @@
|
||||
try
|
||||
{
|
||||
var command = await ArtifactDeploymentService.BuildDeployArtifactsCommandAsync();
|
||||
var result = await ArtifactDeploymentService.DeployToAllSitesAsync(command, "system");
|
||||
var user = await GetCurrentUserAsync();
|
||||
var result = await ArtifactDeploymentService.DeployToAllSitesAsync(command, user);
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user