From b8222bff434f597f0ca19e7bfcb1e99f0da6ecc6 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Mon, 21 Aug 2023 15:01:31 +0200 Subject: [PATCH] [auth] fix auth not being cleared after logout --- frontend/src/app/components/menu/menu.component.ts | 9 +++++++-- frontend/src/app/services/api.service.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/components/menu/menu.component.ts b/frontend/src/app/components/menu/menu.component.ts index 04184a8b1..4d038ab87 100644 --- a/frontend/src/app/components/menu/menu.component.ts +++ b/frontend/src/app/components/menu/menu.component.ts @@ -42,8 +42,13 @@ export class MenuComponent implements OnInit { } logout(): void { - this.apiService.logout$().subscribe(); - this.loggedOut.emit(true); + this.apiService.logout$().subscribe(() => { + this.loggedOut.emit(true); + if (this.stateService.env.GIT_COMMIT_HASH_MEMPOOL_SPACE) { + this.userMenuGroups$ = this.apiService.getUserMenuGroups$(); + this.router.navigateByUrl('/'); + } + }); } onLinkClick() { diff --git a/frontend/src/app/services/api.service.ts b/frontend/src/app/services/api.service.ts index 941ac20aa..c6396d1fb 100644 --- a/frontend/src/app/services/api.service.ts +++ b/frontend/src/app/services/api.service.ts @@ -368,7 +368,7 @@ export class ApiService { return of(null); } - localStorage.setItem('auth', null); + localStorage.removeItem('auth'); return this.httpClient.post(`${SERVICES_API_PREFIX}/auth/logout`, { headers: { 'Authorization': auth.token } });