Cannot get the subscribe to end #662
enostavnik
started this conversation in
General
Replies: 1 comment
-
I solved it with a little bit of code if helps someone: inside the subscription of "authState.subscribe(user => {......}) I added condition if(user===null) { return; } this solved the one part. in package... socialauth.service.js there is a ReplaySubject(1) on line 20. The replay subject emits all the values in a service that were ever emited. So the user data gets emitted over and over and forces it to log in. Change it to BehaviourSubject(1) All regards to the maker though. Great job. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Here's the deal: The facebook login is working great, I log in and post the data to my server and get the bearer token and all, but when i log out of my angular application i'm redirecting back to login screen with social login code. And the subscribe function gets executed automatically again and i get loged in back again.
here's the code...
`
this.socialSub = this.authSocialService.authState.subscribe((user) => {
console.log('entering');
this.user = user;
this.authSub = this.authService.csrfToken().subscribe(() => {
this.socialSignInSub = this.authService.facebookLogin({
id: user.id,
name: user.name,
email: user.email,
profile_image: user.photoUrl
}).subscribe((result:any) => {
this.responseHandler(result);
this.authState.setAuthState(true);
this.loginForm.reset();
this.router.navigate(['uporabniski-racun/nadzorna-plosca']);
});
});
`
this is in ngOnInit... and the in ngOnDestroy i destroy the subscription. But it gets executed again when visiting the login page.
ngOnDestroy(): void { this.authSub.unsubscribe(); this.signInSub.unsubscribe(); this.socialSub.unsubscribe(); this.socialSignInSub.unsubscribe(); }
Beta Was this translation helpful? Give feedback.
All reactions