Skip to content
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

Persist session after refresh #741

Open
godtierbatuhan99 opened this issue Dec 6, 2023 · 3 comments
Open

Persist session after refresh #741

godtierbatuhan99 opened this issue Dec 6, 2023 · 3 comments

Comments

@godtierbatuhan99
Copy link

Any idea how to persist the user's session after a googe LOGIN? From google we receive apparently an id_token... tried saving that in local storage but it has no effect. A silent authentication doensn't really work as well...

@VictorZakharov
Copy link

Also it's interesting that the demo page can log in automatically, but having the same code in my app needs to click the button. I don't understand why the behavior is different.

@lwestfall
Copy link

I duplicated this issue by accident in #747. I'll close and track here instead.

GoogleLoginProvider should persist the token(s?) to localStorage, and try to get them on initialize so it can instantiate _socialUser when present.

The issue is that on browser refresh for a signed-in user, _socialUser will always be null unless the user signs back in (even if we persist the token outside of the provider). This defeats any possibility of refreshing the token after a refresh (which itself seems broken, see #745)

I can attempt a PR this week.

Details to work out (some are notes to self):

  • How to handle expired tokens (should it not instantiate _socialUser in this case?)
  • signOut should clear anything the provider persists

@sscots
Copy link

sscots commented Feb 22, 2024

+1
My issue is that if a user goes directly to a protected page, then I don't want to redirect them to a login page.

So I have a canActivate waiting on authState. If they aren't logged in, authState returns null 1 time. If they are logged in, it returns null 1st then the social user 2nd.
How do I know if authState is going to return once or twice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants