gothinkster / aspnetcore-realworld-example-app

ASP.NET Core backend implementation for RealWorld
https://realworld.io
MIT License
1.94k stars 549 forks source link

Missing app.UseAuthentication()? #64

Closed aeslinger0 closed 4 years ago

aeslinger0 commented 5 years ago

I must have done something differently because someone would have raised a concern before this, but I could not get _httpContextAccessor.HttpContext.User?.Claims?.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value; in CurrentUserAccessor to return a value. In fact, User.Claims was always empty.

I fixed the problem by adding app.UseAuthentication(); above app.UseMvc(); in Startup.cs, but I thought I'd mention this in case I did something wrong. How are others getting the claims to appear without this line?

adamhathcock commented 5 years ago

This might have been introduced when I upgraded versions. Do you mind making a pull request for this issue?

adamhathcock commented 4 years ago

Fixed. Didn't notice as I wasn't using that!