I have build custom authorization module based on Identity. Permissions from db are loaded to Claims with UserClaimsPrincipalFactory which works great but happens only on login.
When granting new permission I think I have two options:
- Add claim to current ClaimsIdentity
- Refresh all claims by recreating identity
The problem is when i try to add claim with user.Identity.AddClaim() it doesn't persist when page is reloaded.
And I cannot find information how to reload ClaimsIdentity.
user.Identity.AddClaim()is just a method to add claim onClaimsIdentitywhich is of course not related to Identity, what you need isUserManager.AddClaimAsyncwhich should persist your claim.CreateAsyncandGenerateClaimsAsyncare only called on sign in.