Use proper database context in new server.

This commit is contained in:
2024-05-03 22:54:50 +01:00
parent 7bcaf5b1b0
commit 67cde54e37
38 changed files with 174 additions and 869 deletions

View File

@@ -1,5 +1,4 @@
using System.Security.Claims;
using Aaru.Server.New.Data;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Server;
using Microsoft.AspNetCore.Identity;
@@ -21,15 +20,14 @@ sealed class IdentityRevalidatingAuthenticationStateProvider
// Get the user manager from a new scope to ensure it fetches fresh data
await using AsyncServiceScope scope = scopeFactory.CreateAsyncScope();
UserManager<ApplicationUser> userManager =
scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();
UserManager<IdentityUser> userManager = scope.ServiceProvider.GetRequiredService<UserManager<IdentityUser>>();
return await ValidateSecurityStampAsync(userManager, authenticationState.User);
}
async Task<bool> ValidateSecurityStampAsync(UserManager<ApplicationUser> userManager, ClaimsPrincipal principal)
async Task<bool> ValidateSecurityStampAsync(UserManager<IdentityUser> userManager, ClaimsPrincipal principal)
{
ApplicationUser? user = await userManager.GetUserAsync(principal);
IdentityUser? user = await userManager.GetUserAsync(principal);
if(user is null) return false;