using Microsoft.AspNetCore.Identity; using BlazorApp1.Data; namespace BlazorApp1.Components.Account; internal sealed class IdentityUserAccessor( UserManager userManager, IdentityRedirectManager redirectManager) { public async Task GetRequiredUserAsync(HttpContext context) { var 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; } }