using Aaru.Server.New.Data; using Microsoft.AspNetCore.Identity; namespace Aaru.Server.New.Components.Account; sealed class IdentityUserAccessor(UserManager userManager, IdentityRedirectManager redirectManager) { public async Task GetRequiredUserAsync(HttpContext context) { ApplicationUser? user = await userManager.GetUserAsync(context.User); if(user is null) { redirectManager.RedirectToWithStatus("Account/InvalidUser", $"Error: Unable to load user with ID '{userManager.GetUserId(context.User)}'.", context); } return user; } }