feat(adminui): thread User.Identity.Name into Deployments createdBy (F18)

Injects AuthenticationStateProvider and reads the current user's identity
name on Deploy click, replacing the "(current user)" placeholder.
Anonymous case falls back to "(anonymous)" — should never hit in practice
since the page requires FleetAdmin/ConfigEditor.
This commit is contained in:
Joseph Doherty
2026-05-26 06:17:53 -04:00
parent dfc143cdeb
commit b266f63cd7

View File

@@ -1,5 +1,6 @@
@page "/deployments"
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.EntityFrameworkCore
@using ZB.MOM.WW.OtOpcUa.Commons.Interfaces
@using ZB.MOM.WW.OtOpcUa.Commons.Messages.Admin
@@ -12,6 +13,7 @@
@inject IDbContextFactory<OtOpcUaConfigDbContext> DbFactory
@inject IAdminOperationsClient AdminOps
@inject AuthenticationStateProvider AuthState
@rendermode InteractiveServer
<PageTitle>Deployments</PageTitle>
@@ -103,8 +105,10 @@
_lastMessage = null;
try
{
var auth = await AuthState.GetAuthenticationStateAsync();
var createdBy = auth.User.Identity?.Name ?? "(anonymous)";
var result = await AdminOps.StartDeploymentAsync(
createdBy: "(current user)", // F18: thread HttpContext.User.Identity.Name through
createdBy: createdBy,
ct: CancellationToken.None);
_lastSuccess = result.Outcome == StartDeploymentOutcome.Accepted;