In a Asp.net Mvc 6 website I customized the out-of-the-box AccountController
so that I add a custom Claim before calling userManager.CreateAsync()
, both when registering
Register()
method of the controllerExternalLoginConfirmation()
of the controllerNow what I'd like to do is, immediately after the user logs in, both
Login()
method after calling signInManager.PasswordSignInAsync()
andExternalLoginCallback()
method after calling signInManager.ExternalLoginSignInAsync()
...to retrieve that claim, ideally without hitting the DB to get the User.
I noticed that if I look at User directly after sign-in, the Claims collection is empty. However, if I look at it in a subsequent controller action the Claims collection is populated and has my custom claim in it.
The question is, why isn't the Claims populated immediately after sign-in (I guess the sign-in code doesn't refresh the CurrentPrincipal?) and is there another place to check directly after sign-in to get the claims without hitting the DB?
You could try to implement your own ApplicationUserStore and fill whatever properties of the user (or entity which is used as identity entity) you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With