Scaffolded project
This commit is contained in:
commit
17a561094a
123 changed files with 64313 additions and 0 deletions
19
Components/Account/IdentityUserAccessor.cs
Normal file
19
Components/Account/IdentityUserAccessor.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using Microsoft.AspNetCore.Identity;
|
||||
using WorkTracker.Data;
|
||||
|
||||
namespace WorkTracker.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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue