0
SamirBoutazzout created
Hey guys, i'm trying to fix an issue I have on the frontend. I would like to clear the sessionStorage from an item I set during the session of a user. I've been looking around on the documentation and google but I couldn't find an answer. Is there a hook or a service exposed in Angular where I can clear the session on logout? Basically, I want to clear the sessionStorage when the user logs out. The issue i'm having is when I logout with an account, and log in with another, the items from the previous session are persisted and this is causing an issue.
Thank you
- ABP Framework version: v6.0.2 Commercial
- UI Type: Angular
- Database System: EF Core (PostgreSQL)
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
2 Answer(s)
-
0
Hello SamirBoutazzout, Can you please try this. Try to add this code in
app.component.ts
file.import { AuthService } from '@abp/ng.core'; import { Router } from '@angular/router'; import { OAuthService } from 'angular-oauth2-oidc'; import { filter, tap } from 'rxjs'; constructor(private oAuthService: OAuthService , private router: Router, private authService: AuthService) { this.oAuthService.events .pipe(filter(event => event?.type === 'logout'), tap(() => { sessionStorage.clear(); })).subscribe(); } }
-
0
Hi Anjali_Musmade,
Thank you very much. That worked like a charm. I appreciate it.