fe5ff81c98
## Overview This PR completes the architectural consolidation of the web project and stabilizes the Identity-based authentication flow for the NexusReader application. It also refines the UI aesthetic for the Book Ingestion Modal as requested in #33. ## Key Changes - **Project Consolidation**: Fully merged `NexusReader.Web.New` into `NexusReader.Web`. This includes updating all namespace references, VS Code launch/task configurations, and CI/CD (`Dockerfile`). - **Identity Stabilization**: - Implemented `IIdentityService` on the server using `SignInManager<NexusUser>` and `UserManager<NexusUser>`. - Fixed registration logic to include mandatory fields (`SubscriptionPlanId`, `TenantId`). - Updated `Login.razor` to force a page reload on successful login, ensuring proper synchronization of authentication cookies between SignalR and the browser. - **UI/UX Refinement**: - Updated `BookIngestionModal` styling to follow the **Nexus Neon** design system. - Added premium button styles with hover effects and glows. - Improved modal layout and interaction feedback (shimmer effects, spinner colors). - **Cleanup**: Removed obsolete interfaces and constants that were superseded by newer Application layer implementations. ## Verification - Successfully built the solution: `dotnet build NexusReader.slnx --no-restore` - Verified project structure and file moves. - Validated server-side authentication logic. Fixes #33 --------- Co-authored-by: Marek Jasiński <jasins.marek@gmail.com> Reviewed-on: #40 Co-authored-by: Antigravity <antigravity@google.com> Co-committed-by: Antigravity <antigravity@google.com>
67 lines
3.2 KiB
C#
67 lines
3.2 KiB
C#
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using NexusReader.Application.Abstractions.Services;
|
|
using NexusReader.Web.Client.Services;
|
|
using NexusReader.UI.Shared.Services;
|
|
using NexusReader.Application;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.AI;
|
|
using NexusReader.Data.Persistence;
|
|
|
|
|
|
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
|
|
|
// Platform & UI Services
|
|
builder.Services.AddScoped<IPlatformService, WebPlatformService>();
|
|
builder.Services.AddScoped<INativeStorageService, WebStorageService>();
|
|
builder.Services.AddScoped<IThemeService, ThemeService>();
|
|
builder.Services.AddScoped<IQuizStateService, QuizStateService>();
|
|
builder.Services.AddScoped<IFocusModeService, FocusModeService>();
|
|
builder.Services.AddScoped<IReaderNavigationService, ReaderNavigationService>();
|
|
builder.Services.AddScoped<IKnowledgeGraphService, KnowledgeGraphService>();
|
|
builder.Services.AddScoped<IReaderInteractionService, ReaderInteractionService>();
|
|
builder.Services.AddScoped<KnowledgeCoordinator>();
|
|
builder.Services.AddScoped<ISyncService, SyncService>();
|
|
|
|
// Identity & Auth Services
|
|
builder.Services.AddOptions();
|
|
builder.Services.AddAuthorizationCore();
|
|
builder.Services.AddScoped<IIdentityService, IdentityService>();
|
|
builder.Services.AddScoped<NexusAuthenticationStateProvider>();
|
|
builder.Services.AddScoped<AuthenticationStateProvider>(sp => sp.GetRequiredService<NexusAuthenticationStateProvider>());
|
|
builder.Services.AddCascadingAuthenticationState();
|
|
|
|
// AI & Content Services
|
|
builder.Services.AddScoped<IKnowledgeService, WasmKnowledgeService>();
|
|
|
|
builder.Services.AddTransient<NexusReader.Web.Client.Handlers.AuthenticationHeaderHandler>();
|
|
builder.Services.AddHttpClient("NexusAPI", client =>
|
|
{
|
|
client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress);
|
|
}).AddHttpMessageHandler<NexusReader.Web.Client.Handlers.AuthenticationHeaderHandler>();
|
|
|
|
builder.Services.AddScoped(sp => sp.GetRequiredService<IHttpClientFactory>().CreateClient("NexusAPI"));
|
|
|
|
// Dummy registrations for server-only handlers to satisfy DI validation
|
|
builder.Services.AddSingleton<IDbContextFactory<AppDbContext>>(new ThrowingDbContextFactory());
|
|
builder.Services.AddSingleton<IEmbeddingGenerator<string, Embedding<float>>>(new ThrowingEmbeddingGenerator());
|
|
|
|
builder.Services.AddApplication();
|
|
builder.Services.AddScoped<IEpubReader, WasmEpubReader>();
|
|
builder.Services.AddScoped<IEpubMetadataExtractor, WasmEpubMetadataExtractor>();
|
|
|
|
await builder.Build().RunAsync();
|
|
|
|
public class ThrowingDbContextFactory : IDbContextFactory<AppDbContext>
|
|
{
|
|
public AppDbContext CreateDbContext() => throw new NotSupportedException("DbContext cannot be used in WASM client.");
|
|
}
|
|
|
|
public class ThrowingEmbeddingGenerator : IEmbeddingGenerator<string, Embedding<float>>
|
|
{
|
|
public void Dispose() { }
|
|
public Task<GeneratedEmbeddings<Embedding<float>>> GenerateAsync(IEnumerable<string> values, EmbeddingGenerationOptions? options = null, CancellationToken cancellationToken = default)
|
|
=> throw new NotSupportedException("Embedding generation cannot be used in WASM client.");
|
|
public object? GetService(Type serviceType, object? serviceKey = null) => null;
|
|
}
|