© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
1 reply
PontiacGTX

❔ Invalidating Claims from previous sessions claims when Logging In

I am using ASP.NET Core 2.0 AND IdentityServer(4?) and I need to invalidate the previous login when this user logins but I see that calling UpdateSecurityStampAsync logs me out from all previous login even tho I make it login once more...(this event is called everytime it logins but i dont know hwo ot invalidate the previous logins, do you mind helping me? thank you
  o.Events.OnSigningIn = async ctx =>
                     {
                         Console.WriteLine("SignIn");
                         var principal = ctx.Principal;
                         if ((ctx.Principal?.Identity is ClaimsIdentity claimIdentity))
                         {
                             var mgr = ctx.HttpContext.RequestServices.GetRequiredService<SignInManager<ApplicationUser>>();
                             var user = await mgr.UserManager.FindByNameAsync(claimIdentity.Name);
                              var res =mgr.UserManager.UpdateSecurityStampAsync(user).Result;
                             if(res.Succeeded)
                             {
                                if(!mgr.IsSignedIn(ctx.Principal))
                                 await mgr.SignInAsync(user, true);
                             }

                         }

                     };
  o.Events.OnSigningIn = async ctx =>
                     {
                         Console.WriteLine("SignIn");
                         var principal = ctx.Principal;
                         if ((ctx.Principal?.Identity is ClaimsIdentity claimIdentity))
                         {
                             var mgr = ctx.HttpContext.RequestServices.GetRequiredService<SignInManager<ApplicationUser>>();
                             var user = await mgr.UserManager.FindByNameAsync(claimIdentity.Name);
                              var res =mgr.UserManager.UpdateSecurityStampAsync(user).Result;
                             if(res.Succeeded)
                             {
                                if(!mgr.IsSignedIn(ctx.Principal))
                                 await mgr.SignInAsync(user, true);
                             }

                         }

                     };
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Invalidating inherited Properties Tree in WPF
C#CC# / help
2y ago
❔ Select next/previous item from a list when function called
C#CC# / help
3y ago
✅ Issues logging in from frontend via backend API
C#CC# / help
2y ago
Logging from disconnected Business logic
C#CC# / help
15mo ago