When implementing Google login, the this.authService.authState.subscribe() callback in the Login.component.ts is subscribed. However, upon user logout and returning to the login page, the authState callback is triggered again, creating the impression of logging in anew. Despite attempting to unsubscribe from the observable, the issue persists.
// In Login.component.ts
// Subscribe to authState callback
const authSubscription = this.authService.authState.subscribe((user) => {
this.user = user;
this.loggedIn = (user != null);
});
// ...
// Upon logout or component destruction, unsubscribe to prevent unwanted triggers
ngOnDestroy() {
authSubscription.unsubscribe();
}
Despite the effort to unsubscribe using authSubscription.unsubscribe(), the callback is still being invoked.
When implementing Google login, the
this.authService.authState.subscribe()
callback in theLogin.component.ts
is subscribed. However, upon user logout and returning to the login page, theauthState
callback is triggered again, creating the impression of logging in anew. Despite attempting to unsubscribe from the observable, the issue persists.Despite the effort to unsubscribe using
authSubscription.unsubscribe()
, the callback is still being invoked.