diff --git a/src/app/app.component.html b/src/app/app.component.html index 63a2559..8016415 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -4,7 +4,7 @@ Browse Catalog Query Tool - + @@ -16,7 +16,7 @@
- +
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 3e1804b..bfcf8e8 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -8,27 +8,27 @@ import { Subscription } from 'rxjs'; styleUrls: ['./app.component.scss'], }) export class AppComponent implements OnInit, OnDestroy { + isLoggedIn = false; username: string | null = null; + private loginStateSubscription?: Subscription; private usernameSubscription?: Subscription; constructor(private authService: AuthService) {} ngOnInit(): void { + this.loginStateSubscription = this.authService.isLoggedIn$.subscribe((status) => { + this.isLoggedIn = status; + }); + this.usernameSubscription = this.authService.username$.subscribe((username) => { this.username = username; }); - - if (this.isLoggedIn()) { - this.username = this.authService.getUsername(); - } } ngOnDestroy(): void { + this.loginStateSubscription?.unsubscribe(); this.usernameSubscription?.unsubscribe(); } - isLoggedIn(): boolean { - return this.authService.isLoggedIn(); - } logout() { this.authService.logout(); diff --git a/src/app/components/authentication/authentication.component.html b/src/app/components/authentication/authentication.component.html index e1c5b8c..6e72d56 100644 --- a/src/app/components/authentication/authentication.component.html +++ b/src/app/components/authentication/authentication.component.html @@ -1,4 +1,4 @@ -