0

I am trying to get the currently logged in Users claims (from the database), but everything I try either requires a ClaimsPrinicpal or a User which I don't seem to have. Ive tried searching forums, and searching SO with no luck. What am I missing?

public IEnumerable<Claim> PullCurrentUserClaims(UserManager<ApplicationUser> u)
{
    return u.;
}
Rilcon42
  • 9,584
  • 18
  • 83
  • 167
  • There is an extension method called GetClaims() in the UserManager object. Please refer to the link. https://msdn.microsoft.com/en-us/library/mt151638(v=vs.108).aspx – ngeksyo Apr 04 '18 at 18:11
  • @ngeksyo that looks perfect, but I don't know how to get the user id of the logged in user – Rilcon42 Apr 04 '18 at 18:12
  • Have you tried any of these? https://stackoverflow.com/questions/21404935/mvc-5-access-claims-identity-user-data?rq=1 Do they all have a blank identity? – tgolisch Apr 04 '18 at 20:48
  • @Rilcon42 based on your method signature there is no parameter userId. If you are under a controller you can use this this.User.Identity.GetUserId(), assuming that you're userId is of type int. – ngeksyo Apr 05 '18 at 02:24

0 Answers0