How to create a security stamp value for asp.net identity (IUserSecurityStampStore)

流过昼夜 提交于 2019-12-03 23:25:08

Out of the documentation of the identity implementation for the entity-framework, it seems that it can be any random value:

IdentityUser.SecurityStamp Property

A guid seems therefore fine and the following code should be reliable also with future versions of asp.net identity.

Guid.NewGuid().ToString("D")

ASP.NET Identity UserManager provides method UpdateSecurityStampAsync(string userId)which will automatically update users security-stamp. So that next time validateInterval ends user will be automatically logged-out and forced to sign.in again.

UserManager.UpdateSecurityStampAsync(userId);

a bit late to the party, but these seem to work just fine:

        await _userManager.UpdateSecurityStampAsync(user);
        await _userManager.UpdateNormalizedEmailAsync(user);
        await _userManager.UpdateNormalizedUserNameAsync(user);
        await _userManager.SetLockoutEnabledAsync(user, true);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!