From 7fd8790750b151d37566ef6b0f91fd5837c93cf0 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Mon, 28 Aug 2023 09:29:13 +0200 Subject: [PATCH] [auth] fix blinking profile picture --- .../app/components/master-page/master-page.component.ts | 3 +-- frontend/src/app/components/menu/menu.component.ts | 5 +++++ .../components/global-footer/global-footer.component.ts | 9 +-------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/components/master-page/master-page.component.ts b/frontend/src/app/components/master-page/master-page.component.ts index 49bed7a5d..a92f77cf9 100644 --- a/frontend/src/app/components/master-page/master-page.component.ts +++ b/frontend/src/app/components/master-page/master-page.component.ts @@ -29,7 +29,6 @@ export class MasterPageComponent implements OnInit { networkPaths: { [network: string]: string }; networkPaths$: Observable>; footerVisible = true; - userAuth: any | undefined; user: any = undefined; servicesEnabled = false; menuOpen = false; @@ -94,7 +93,7 @@ export class MasterPageComponent implements OnInit { } refreshAuth(): void { - this.apiService.getUserInfo$().subscribe(user => this.user = user); + this.user = this.storageService.getAuth()?.user ?? null; } hamburgerClick(event): void { diff --git a/frontend/src/app/components/menu/menu.component.ts b/frontend/src/app/components/menu/menu.component.ts index e6ba848bc..2fb5c34d1 100644 --- a/frontend/src/app/components/menu/menu.component.ts +++ b/frontend/src/app/components/menu/menu.component.ts @@ -30,6 +30,11 @@ export class MenuComponent implements OnInit { ngOnInit(): void { this.userAuth = this.storageService.getAuth(); + if (this.userAuth && this.userAuth.user && !this.userAuth.user.imageMd5) { + this.logout(); + return; + } + if (this.stateService.env.GIT_COMMIT_HASH_MEMPOOL_SPACE) { this.userMenuGroups$ = this.apiService.getUserMenuGroups$(); } diff --git a/frontend/src/app/shared/components/global-footer/global-footer.component.ts b/frontend/src/app/shared/components/global-footer/global-footer.component.ts index 75d989ff7..e76a5de0d 100644 --- a/frontend/src/app/shared/components/global-footer/global-footer.component.ts +++ b/frontend/src/app/shared/components/global-footer/global-footer.component.ts @@ -28,7 +28,6 @@ export class GlobalFooterComponent implements OnInit { networkPaths: { [network: string]: string }; currentNetwork = ''; loggedIn = false; - username = null; urlSubscription: Subscription; isServicesPage = false; @@ -64,13 +63,7 @@ export class GlobalFooterComponent implements OnInit { }); this.urlSubscription = this.route.url.subscribe((url) => { - this.loggedIn = JSON.parse(this.storageService.getValue('auth')) !== null; - const auth = JSON.parse(this.storageService.getValue('auth')); - if (auth?.user?.username) { - this.username = auth.user.username; - } else { - this.username = null; - } + this.loggedIn = this.storageService.getAuth() !== null; this.cd.markForCheck(); }) }