我正在使用ASP.NET MVC,Identity2。
我已添加“名字”自定义ClaimPrincipal
:
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser, long> manager)
{
var userIdentity = await manager.CreateIdentityAsync(
this,
DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
userIdentity.AddClaim(new Claim("FirstName", FirstName));
return userIdentity;
}
如果更新“ FirstName”的值,则需要注销并重新登录,以更新“ FirstName”声明。是否可以使“名字”声明无效,因此其值被强制刷新?
我看过this question,它显示了如何更新Claims的值,我想知道是否有更简单的方法来使它们无效。
[当查看MS内置模板时,我注意到他们在更改用户凭据(例如密码,2因子身份验证等)后始终会呼叫SignInManager.SignInAsync
。