Add identity first iteration

This commit is contained in:
2025-10-06 18:45:27 +09:00
parent cb8b9bbf6b
commit c29f7ef7dd
16 changed files with 1046 additions and 10 deletions

View File

@ -0,0 +1,18 @@
using Hcs.WebApp.Data;
using Microsoft.AspNetCore.Identity;
namespace Hcs.WebApp.Identity
{
internal sealed class IdentityUserAccessor(UserManager<AppUser> userManager, IdentityRedirectManager redirectManager)
{
public async Task<AppUser> GetRequiredUserAsync(HttpContext context)
{
var user = await userManager.GetUserAsync(context.User);
if (user is null)
{
redirectManager.RedirectToWithStatus("account/invalid_user", $"Ошибка: Не удалось загрузить пользователя с идентификатором '{userManager.GetUserId(context.User)}'", context);
}
return user;
}
}
}