How to sign out previous login when user log in through another browser in .net core? I referred to this link but confused about how to use it. enter link description here
Asked
Active
Viewed 242 times
2 Answers
0
You simply call UpdateSecurityStampAsync on your UserManager instance with the user in question. Then sign them in. This won't automatically log out other sessions, because there's a client-side component that must come into play. However, on the next request made from another browser, the cookie there will be invalidated because the security stamp won't match, and then the user will be effectively logged out.
Chris Pratt
- 232,153
- 36
- 385
- 444
-
It should be noted that the [ValidationInterval](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.securitystampvalidatoroptions.validationinterval) property determines when to check which defaults to 30 mins. – Mark G May 02 '18 at 17:24
0
It worked for me doing like: After login done:
var loggedinUser = await _userManager.FindByEmailAsync(model.Email);
if (loggedinUser != null)
{
var Securitystamp = await _userManager.UpdateSecurityStampAsync(loggedinUser);
}
and in StartUp.cs
services.Configure<SecurityStampValidatorOptions>(options => options.ValidationInterval = TimeSpan.FromSeconds(0));
swapnil
- 27
- 1
- 1
- 9