Fix W3-T3 review: attach JWT in DeleteTrackDialog, int→long TrackId, log RemoveResourceAsync failure, drop redundant {Reason} log param
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user