Fix W3-T3 review: attach JWT in DeleteTrackDialog, int→long TrackId, log RemoveResourceAsync failure, drop redundant {Reason} log param

This commit is contained in:
Daniel Harvey
2026-05-18 15:42:58 -04:00
parent 4a59df6baa
commit 1738d262de
4 changed files with 31 additions and 18 deletions
@@ -1,6 +1,8 @@
@using System.Net.Http
@using System.Net.Http.Headers
@using Microsoft.AspNetCore.Components
@inject IHttpClientFactory HttpClientFactory
@inject AuthBlocksWeb.Services.ITokenService TokenService
<MudDialog>
<DialogContent>
@@ -34,7 +36,7 @@
@code {
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = default!;
[Parameter] public int TrackId { get; set; }
[Parameter] public long TrackId { get; set; }
[Parameter] public string TrackName { get; set; } = "";
[Parameter] public EventCallback OnDeleted { get; set; }
@@ -48,10 +50,10 @@
try
{
// "DeepDrft.API" is the named client pointing at DeepDrftWeb's own host.
// The Admin role gate on the endpoint is enforced server-side by AuthBlocks;
// the registered HTTP client/auth handler stack attaches the JWT.
var client = HttpClientFactory.CreateClient("DeepDrft.API");
var token = await TokenService.GetAccessTokenAsync();
if (!string.IsNullOrEmpty(token))
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var response = await client.DeleteAsync($"api/cms/track/{TrackId}");
if (response.IsSuccessStatusCode)