Edit Records

This commit is contained in:
2025-12-01 17:56:17 +01:00
parent 7ea5ed506e
commit c8ded1f0a4
11 changed files with 624 additions and 28 deletions

View File

@@ -0,0 +1,35 @@
using DiunaBI.UI.Shared.Services;
namespace DiunaBI.UI.Shared.Handlers;
public class AuthenticationHandler : DelegatingHandler
{
private readonly TokenProvider _tokenProvider;
public AuthenticationHandler(TokenProvider tokenProvider)
{
_tokenProvider = tokenProvider;
}
protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request,
CancellationToken cancellationToken)
{
// Get token from TokenProvider
var token = _tokenProvider.Token;
Console.WriteLine($"🔐 AuthenticationHandler: Token = {(string.IsNullOrEmpty(token) ? "NULL" : $"{token[..Math.Min(20, token.Length)]}...")}");
if (!string.IsNullOrEmpty(token))
{
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
Console.WriteLine($"🔐 AuthenticationHandler: Added Bearer token to request");
}
else
{
Console.WriteLine($"🔐 AuthenticationHandler: No token available, request will be unauthorized");
}
return await base.SendAsync(request, cancellationToken);
}
}