finalizare 1.0
This commit is contained in:
+31
-15
@@ -1,28 +1,44 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||
using Blazored.LocalStorage;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using HealthcareManagerUiWebAssem;
|
||||
using HealthcareManagerUiWebAssem.Services.Appointment;
|
||||
using HealthcareManagerUiWebAssem.Services.AdminUserManagement;
|
||||
using HealthcareManagerUiWebAssem.Services.Authentication;
|
||||
using HealthcareManagerUiWebAssem.Services.Http;
|
||||
using HealthcareManagerUiWebAssem.Services.Profile;
|
||||
using HealthcareManagerUiWebAssem.Services.User;
|
||||
using HealthcareManagerUiWebAssem.Services.UserSessionInformation;
|
||||
using HealthcareManagerUiWebAssem.Services.DoctorManagement;
|
||||
using HealthcareManagerUiWebAssem.Services.PatientManagement;
|
||||
using HealthcareManagerUiWebAssem.Services.RequestHttp;
|
||||
|
||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||
builder.RootComponents.Add<App>("#app");
|
||||
builder.RootComponents.Add<HeadOutlet>("head::after");
|
||||
|
||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
|
||||
builder.Services.Configure<ApplicationSettings>(builder.Configuration.GetSection("ApiSettings"));
|
||||
builder.Services.AddHttpClient();
|
||||
// Configure API settings
|
||||
var apiSettings = builder.Configuration.GetSection("ApiSettings").Get<ApplicationSettings>();
|
||||
builder.Services.AddSingleton(apiSettings);
|
||||
|
||||
// Configure custom HttpClient handler
|
||||
builder.Services.AddTransient<AuthenticationHttpMessageHandler>();
|
||||
|
||||
builder.Services.AddHttpClient<IRequestHttpService, RequestHttpService>((sp, httpClient) =>
|
||||
{
|
||||
var settings = sp.GetRequiredService<ApplicationSettings>();
|
||||
httpClient.BaseAddress = new Uri(settings.BaseAddress);
|
||||
}).AddHttpMessageHandler<AuthenticationHttpMessageHandler>();
|
||||
|
||||
builder.Services.AddBlazoredLocalStorage();
|
||||
builder.Services.AddScoped<IUserSessionInformation, UserSessionInformation>();
|
||||
builder.Services.AddScoped<IRequestHttpService, RequestHttpService>();
|
||||
builder.Services.AddScoped<UserService>();
|
||||
builder.Services.AddScoped<IAuthenticationService, AuthenticationService>();
|
||||
builder.Services.AddScoped<IProfileService, ProfileService>();
|
||||
builder.Services.AddScoped<IAppointmentService, AppointmentService>();
|
||||
builder.Services.AddScoped<IAdminManagementService, AdminManagementService>();
|
||||
builder.Services.AddScoped<IPatientManagementService, PatientManagementService>();
|
||||
builder.Services.AddScoped<IDoctorManagementService, DoctorManagementService>();
|
||||
|
||||
await builder.Build().RunAsync();
|
||||
// Register CustomAuthenticationStateProvider as the AuthenticationStateProvider
|
||||
builder.Services.AddScoped<AuthenticationStateProvider, CustomAuthenticationStateProvider>();
|
||||
builder.Services.AddAuthorizationCore(config =>
|
||||
{
|
||||
config.AddPolicy("AdminOnly", policy => policy.RequireRole(UserRoles.Admin));
|
||||
config.AddPolicy("DoctorOnly", policy => policy.RequireRole(UserRoles.Doctor));
|
||||
config.AddPolicy("PatientOnly", policy => policy.RequireRole(UserRoles.Patient));
|
||||
});
|
||||
|
||||
await builder.Build().RunAsync();
|
||||
Reference in New Issue
Block a user