abacritt/angularx-social-login

Persistent authState Callback Trigger on Logout/Return to Login Page.

Opened this issue · 2 comments

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.

Before anyone says anything, last month it was working fine.

window.location.reload();