Okey, so i'm getting impatient here. :) I'm trying to access my signed in user through HttpContext.User by accessing the IHttpContextAccessor but no user is available, nor any claims. Dotnet core 3.1 is being used here. This is basically how I understand it: Sign in user with HttpContext.SignInAsync(... and then the context is available through the IHttpContextAccessor outside controllers. Now, the context is available but cant find any accessible user information from the signin. I do see that the cookies are correctly attached to the requests but there is some transformation not being done. Does anyone know what I am missing?
//My controller action:
var claimsIdentity = new ClaimsIdentity("Application");
claimsIdentity.AddClaim(emailClaim);
... more claims
await HttpContext.SignInAsync(
"Application",
new ClaimsPrincipal(claimsIdentity)
);
// Startup.cs:ConfigureServices
services.AddHttpContextAccessor();
// In a MyClass
MyClass(IHttpContextAccessor accessor)
{
accessor.HttpContext.Claims; // Nothing
}
