How to sign out other user in ASP.NET Core Identity

Mariusz Jamro

How can i sign out another user (not the currently logged one) in ASP.NET Core Identity.

I know there is a SignOutAsync() method in SignInManager, but there seems to be no override accepting user as argument. I'm looking for something like:

signInManager.SignOutAsync(user);
VahidN

First update the security stamp of that user:

await userManager.UpdateSecurityStampAsync(user)

Then that user won't be noticed the changes until the arrival of the SecurityStampValidationInterval. So set it to Zero for the immediate logout:

services.AddIdentity<User, Role>(identityOptions =>
{
   // enables immediate logout, after updating the user's stat.
   identityOptions.SecurityStampValidationInterval = TimeSpan.Zero;
}

Update: For ASP.NET Core Identity 2.x

services.Configure<SecurityStampValidatorOptions>(options =>
{
    // enables immediate logout, after updating the user's stat.
    options.ValidationInterval = TimeSpan.Zero;   
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

ASP.net Identity 2.0 Sign-out another user

ASP.net Core Identity Sign in as another user from Administrator

ASP .NET Core - sign in as other user / impersonate user and way back

Why sign-in a new user when using ASP.NET Core Identity and token-based auth?

Why ASP.NET Core MVC 3.1 project wont let me sign in with a register user using Identity

How to get Asp.net Core Identity User in View

ASP.Net Core API: How to link User Identity to a Contact

Asp.net Identity logout other user

ASP.NET Core Identity user groups

How to get JWT authenticated sign-in user from identity claims in asp.net web api

Google sign-in provider without ASP.NET Core Identity

How do I seed user roles in Identity ASP.NET Core 2.1 (Identity Scaffolded)

ASP.Net Core how to get the user role in EF Core and Identity

How to customize sign out page in asp net core 3.1 when Azure Active Directory used in a Blazor application

How can I have multiple Identity user types when using ASP.NET Core Identity and Entity Framework Core?

How to check if user is logged in to ASP.NET Core web application when using ASP.NET Core Web API to house identity

Cookies Not Deleting in Asp.Net Core on Sign Out

How to create New user using Asp.net mvc identity out side from Accountcontroller?

How to edit a user in ASP.NET Identity

Why my asp.net identity -user will log out automatically

Using ASP.net Identity user with other tables

How to ask for password when user open settings page in ASP.NET Core Identity?

What are ai_user and ai_session cookies in ASP NET Core Identity and how to configure it?

How to get logged-in user name in the constructor of a controller in ASP.NET Core Identity

How to retrieve Google profile picture from logged in user with ASP.Net Core Identity?

How do I get the user details straight after login using Identity on ASP.NET Core?

How to get user claims after signin through SignInManager in ASP .NET CORE Identity?

How many claims can a Role/User have in ASP.Net.Core.Identity?

How to disable account if user login fails continuously in Asp.Net Core identity