i am using google sign in to verify my users with the help of angularx-social-login, login and logout is working, but i want the user to keep logged if it doesnt logout,that means, if i close a tab or the browser, the next time doesnt have to log in again. i use a guard to protect the routes that are lazily loaded.
the problem is autologin: true doesnt work, whenever i reload the page or open a new tab, the guard kicks me to the login page
authService
userState() {
this.socialAuthService.authState.subscribe((user) => {
this.user = user;
this.loggedIn = (user != null);
});
}
authGuard
if (!this.authService.loggedIn) {
this.router.navigate([localUrls.login])
}
return true
Edit: i kinda debbuged and finded that the behaviour is as follows:
1- open new tab
2- guard checks loggedIn variable, its false
3- guard redirects to login page
4- authService receives the logged user, loggedIn is set to true
5- get stuck in the login page with the user actually logged in
anyone has a hint to solve this?