feat: introduce IConceptsMapService abstraction with server and WASM implementations and update knowledge processing flow
This commit is contained in:
@@ -9,6 +9,7 @@ using NexusReader.Application.Queries.User;
|
||||
using MediatR;
|
||||
using NexusReader.Application.Constants;
|
||||
using NexusReader.Application.Abstractions.Services;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
|
||||
namespace NexusReader.Web.Services;
|
||||
|
||||
@@ -19,6 +20,7 @@ public class ServerIdentityService : IIdentityService
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IMediator _mediator;
|
||||
private readonly INativeStorageService _storageService;
|
||||
private readonly AuthenticationStateProvider _authStateProvider;
|
||||
|
||||
public event Func<Task>? OnStateInvalidated;
|
||||
|
||||
@@ -27,13 +29,15 @@ public class ServerIdentityService : IIdentityService
|
||||
SignInManager<NexusUser> signInManager,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IMediator mediator,
|
||||
INativeStorageService storageService)
|
||||
INativeStorageService storageService,
|
||||
AuthenticationStateProvider authStateProvider)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_signInManager = signInManager;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_mediator = mediator;
|
||||
_storageService = storageService;
|
||||
_authStateProvider = authStateProvider;
|
||||
}
|
||||
|
||||
public async Task<Result> LoginAsync(string email, string password, bool rememberMe = false)
|
||||
@@ -107,7 +111,14 @@ public class ServerIdentityService : IIdentityService
|
||||
|
||||
public async Task<Result<UserProfileDto>> GetProfileAsync()
|
||||
{
|
||||
var user = _httpContextAccessor.HttpContext?.User;
|
||||
var authState = await _authStateProvider.GetAuthenticationStateAsync();
|
||||
var user = authState.User;
|
||||
|
||||
if (user == null || !user.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
user = _httpContextAccessor.HttpContext?.User;
|
||||
}
|
||||
|
||||
if (user == null || !user.Identity?.IsAuthenticated == true) return Result.Fail("Not authenticated.");
|
||||
|
||||
var userId = user.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
Reference in New Issue
Block a user