abacritt / angularx-social-login

Social login and authentication module for Angular 17
630 stars 388 forks source link

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

Open Tweniee opened 7 months ago

Tweniee commented 7 months ago

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.

Tweniee commented 7 months ago

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

hardcorelite commented 2 months ago
window.location.reload();