Is is possible to retrieve and modify claims in a controller after SignIn
has been called? This doesn't work for me:
ClaimsIdentity i = (ClaimsIdentity)HttpContext.GetOwinContext().Authentication.User.Identity;
i.AddClaim(new Claim("type", "value"));
What I need to do is: after login is complete and the user has been doing other things, they POST a form and I need to modify the claims at this point and redirect them to another page. I wonder if this isn't working due to PRG and cookies, or just Identity, or my lack of knowledge?
Update: I actually worked around this by calling SignIn
a second time, which seems to work, but I would guess that has side-effects so it would be nice to know if there is a way to modify these regardless.
Calling SignIn is exactly what you are supposed to do when you want to modify the claims for the user. It basically causes the ClaimsIdentity to be serialized into the cookie, which is why you see the new claims show up on subsequent requests.
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