finalizare 1.0

This commit is contained in:
andrei-mihnea-cerbu
2024-05-21 12:10:53 +03:00
parent f7795f7519
commit 1cc1d34003
11268 changed files with 2102399 additions and 10909 deletions
@@ -0,0 +1,22 @@
using System.Net.Http.Headers;
using Blazored.LocalStorage;
namespace HealthcareManagerUiWebAssem;
public class AuthenticationHttpMessageHandler(ILocalStorageService localStorageService, ApplicationSettings apiSettings)
: DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
CancellationToken cancellationToken)
{
// Add API key to request headers
request.Headers.Add("ApiKey", apiSettings.ApiKey);
// Retrieve JWT token from local storage
var token = await localStorageService.GetItemAsync<string>("authToken", cancellationToken);
if (!string.IsNullOrEmpty(token))
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
return await base.SendAsync(request, cancellationToken);
}
}