Starts in:
1 DAY
7 HRS
39 MIN
15 SEC
Starts in:
1 D
7 H
39 M
15 S
Open Closed

Clear Local Storage after logout #8295


User avatar
0
nabass created

hi where can i find logout logic to clear database for example i added an item to my table this item store in local storage i want when logout and login again with same user to clear this local storage so how can i did it ? i attached simple video to see what i want to do thank you

https://streamable.com/4l44ba

  • ABP Framework version: v8.0.2
  • UI Type: Angular
  • Database System: EF Core (SQL Server)

8 Answer(s)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello ,

    When the logout event is triggered, use JavaScript's localStorage.clear() method to remove all items from the local storage. Please try this once.

    Thank you.

  • User Avatar
    0
    nabass created

    hi i already know localStorage.clear() what i want is (where) to write it in abp angular ? where logout event is triggered ??

  • User Avatar
    0
    nabass created

    i'm using abp angular so it handles the login page automatically so how can i access logout event ?

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello ,

    Please try to this code in app.component.ts file. eg:-

    import { Component } from '@angular/core';
    import { OAuthService } from 'angular-oauth2-oidc';
    import { filter } from 'rxjs';
    
    @Component({
      selector: 'app-root',
    })
    export class AppComponent {
      constructor(private oAuthService: OAuthService) {
        this.oAuthService.events
          .pipe(filter((event) => event?.type === 'logout'))
          .subscribe((event) => {
            // logout event fired
            localStorage.clear();
          });
      }
    }
    

    When i click on logut button debugger was hit

    Thank you,

  • User Avatar
    0
    nabass created

    wow it works big thanks for you but routing disappear why ?

  • User Avatar
    0
    nabass created

    i solved it thank you

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello,

    At my side its work there is nothing any issue check here.

    You can refer this document https://abp.io/docs/8.2/tutorials/book-store/part-02?UI=NG&DB=EF if it is helpful for you.

    Thank you.

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    i solved it thank you

    Great : )

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06