Add Authentication on frontend

This commit is contained in:
2025-04-20 23:23:00 +02:00
parent 772c0fda66
commit 4fd5f71724
14 changed files with 226 additions and 49 deletions

View File

@@ -1,12 +1,16 @@
using System.Net.Http.Json;
using Blazored.LocalStorage;
using GameIdeas.BlazorApp;
using GameIdeas.BlazorApp.Pages.Games.Gateways;
using GameIdeas.BlazorApp.Pages.User.Gateways;
using GameIdeas.BlazorApp.Services;
using GameIdeas.Resources;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
var services = builder.Services;
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
@@ -15,7 +19,7 @@ UriBuilder uriBuilder = new(builder.HostEnvironment.BaseAddress)
Port = 8000
};
builder.Services.AddHttpClient(
services.AddHttpClient(
"GameIdeas.WebAPI",
client =>
{
@@ -23,11 +27,18 @@ builder.Services.AddHttpClient(
client.Timeout = TimeSpan.FromMinutes(3);
});
builder.Services.AddScoped<IHttpClientService, HttpClientService>();
builder.Services.AddScoped<IGameGateway, GameGateway>();
services.AddBlazoredLocalStorage();
services.AddAuthorizationCore();
builder.Services.AddSingleton<TranslationService>();
builder.Services.AddSingleton<Translations>();
services.AddScoped<JwtAuthenticationStateProvider>();
services.AddScoped<IHttpClientService, HttpClientService>();
services.AddScoped<IAuthGateway, AuthGateway>();
services.AddScoped<IGameGateway, GameGateway>();
services.AddSingleton<TranslationService>();
services.AddSingleton<Translations>();
var app = builder.Build();