mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 22:23:12 +00:00
20 lines
688 B
C#
20 lines
688 B
C#
using Data.SeaHavenIndustries;
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
namespace SeaHavenIndustries.Components.Account
|
|
{
|
|
internal sealed class IdentityUserAccessor(UserManager<ApplicationUser> userManager, IdentityRedirectManager redirectManager)
|
|
{
|
|
public async Task<ApplicationUser> 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;
|
|
}
|
|
}
|
|
}
|