Open Closed

Force user logout after a certain period #6430


User avatar
0
devpayoff created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, and please first use the search on the homepage. Provide us with the following info:

  • ABP Framework version: v7.4.1
  • UI Type: Angular
  • Database System: EF Core
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes

We want to manage the users session in such a way that after 20 minutes of inactivity a popup appears that asks the user if he wants to stay connected, if he doesn't press yes he will logout.

How can we do that?

Thank you


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    There is an angular method to clear the login state.

    https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/oauth/src/lib/utils/clear-o-auth-storage.ts#L4

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    devpayoff:

    I used: builder.SetAccessTokenLifetime(TimeSpan.FromMinutes(20)); for making the token expire after 20 minutes.
    
    In angular i subscribed to the token refresh expiration event so when the token expire a modal appear this.oAuthService.events .pipe(filter(event => event.type === 'token_refresh_error')) .subscribe(() => { this.modalVisible = true; }); 
    
    Problem is that when a token expire abp redirect me to login page. How can i remove/override that abp behavior?
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Problem is that when a token expire abp redirect me to login page. How can i remove/override that abp behavior?

    I think the behavior comes from: https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/oauth/src/lib/strategies/auth-flow-strategy.ts#L76-L78

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11