From 623f6dcc433149a41e93ce978ce5060ea46d7589 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 28 Mar 2021 14:52:07 +0300 Subject: Fixed some session storage request that were happening while the user wasn't logged in --- src/app/components/navbar/navbar.component.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/app/components/navbar/navbar.component.ts') diff --git a/src/app/components/navbar/navbar.component.ts b/src/app/components/navbar/navbar.component.ts index 85f07d1..14b8f52 100644 --- a/src/app/components/navbar/navbar.component.ts +++ b/src/app/components/navbar/navbar.component.ts @@ -20,13 +20,14 @@ export class NavbarComponent implements OnInit { this.loggedIn = this._tokenService.getTokenFromSessionStorage() !== ''; this.user = this._userService.getDefaultUser(); - this.user.userName = ''; // so you don't always see a flash of 'Gosho' - this._userService.getUserFromSessionStorageRequest().subscribe({ - next: (res: object) => { - Object.assign(this.user, res); - }, - }); + if (this.loggedIn) { + this._userService.getUserFromSessionStorageRequest().subscribe({ + next: (res: object) => { + Object.assign(this.user, res); + }, + }); + } } goToProfile(): void { -- cgit v1.2.3