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