Open Closed

User logout doesn't work #2377


User avatar
0
dev1.abp.advantiss created
  • ABP Framework version: v4.3.3
  • UI type: Angular
  • DB provider: MongoDB
  • Tiered (MVC) or Identity Server Separated (Angular): yes

I would like to logout current user. I use for it await SignInManager.SignOutAsync(); Also try this await SignInManager.Context.SignOutAsync(); But nothing happened. When refreshing browser page, user is still login in system. Why? How do proper logout?


5 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi @dev1.abp.advantiss, can you try the below code:

    public IdentitySecurityLogManager IdentitySecurityLogManager {get;set;}
    public AbpSignInManager SignInManager {get; set;}
    //or
    //public SignInManager<IdentityUser> SignInManager { get; set; }
    
    await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext()
    {
         Identity = IdentitySecurityLogIdentityConsts.Identity,
         Action = IdentitySecurityLogActionConsts.Logout
    });
    
    await SignInManager.SignOutAsync();
    
  • User Avatar
    0
    dev1.abp.advantiss created

    Hi @dev1.abp.advantiss, can you try the below code:

    public IdentitySecurityLogManager IdentitySecurityLogManager {get;set;} 
    public AbpSignInManager SignInManager {get; set;} 
    //or 
    //public SignInManager<IdentityUser> SignInManager { get; set; } 
     
    await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext() 
    { 
         Identity = IdentitySecurityLogIdentityConsts.Identity, 
         Action = IdentitySecurityLogActionConsts.Logout 
    }); 
     
    await SignInManager.SignOutAsync(); 
    

    Nothing is happened. After this code I check CurrentUser.IsAuthenticated and it's still true.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    But nothing happened. When refreshing browser page, user is still login in system.

    Do you mean Angular app still have the state?

  • User Avatar
    0
    dev1.abp.advantiss created

    But nothing happened. When refreshing browser page, user is still login in system.

    Do you mean Angular app still have the state?

    Yes

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Angular and Identity Server are two separate sites you can try to log out from the angular app.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07