-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
socialAuthService.signout doesn't clear the user and I can't stop autologin. #764
Comments
Hi, guys any updates ? Specially in case of Microsoft, i wanted to my application should logout instead of Microsoft account logout popup. |
Facing the exact same problem. Are there any known workarounds? |
Facing the same problem |
I had a similar issue so putting my solution here in case it helps anyone. What I had was this (logout.ts): ngOnInit(): void {
this._socialAuthService.authState
.pipe(
filter((authState) => !!authState),
switchMap(() => this._socialAuthService.signOut()),
takeUntil(this.destroy$)
)
.subscribe();
} but for some reason, it would sometimes not pass the filter, so changed it to automatically sign out after authenticating with the backend like this on the login page (login.ts): ngOnInit(): void {
this._socialAuthService.authState
.pipe(
filter((authState) => !!authState?.idToken),
switchMap((authState) =>
this._authService.signInWithGoogle(
authState.idToken,
authState.name
)
),
finalize(
async () =>
await this._socialAuthService
.signOut()
.catch((error) =>
console.error(
'There was a problem signing out of social login: ',
error
)
)
),
takeUntil(this.destroy$)
)
.subscribe(this.handleSignInResponse);
} |
I'm on 2.0.0
When I call socialAuthService.signOut(). The service's user property isn't cleared. Is that expected behavior?
The reason I ask is because I have a login component that subscribes to authState which works great. I also have a logout component that routes back to the login component.
The issue I'm running into is that when the login component is re initialized when routed to from logout, the authservice still thinks the user is logged in and is firing my code to load the post login UI for the user (when they should remain logged out). The autologin flag is set to false BTW.
I have registered the providers in one place (app.module.ts) and subscrbing to the service solely in the login component.
My workaround has been to detect that the login page was reached via a logout reroute and doing a location.reload to clear the service (which is hacky as hell)>. I tried unsubscribing from the autservice but that didn't work.
Thanks
The text was updated successfully, but these errors were encountered: