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

State persistent after page refersh #766

Open
Nikhil-Wagh opened this issue May 3, 2024 · 1 comment
Open

State persistent after page refersh #766

Nikhil-Wagh opened this issue May 3, 2024 · 1 comment

Comments

@Nikhil-Wagh
Copy link

Nikhil-Wagh commented May 3, 2024

The user state is lost when I refresh the page. The user is logged out and is again required to complete the login flow.

How to avoid this?

@zooli123
Copy link

I have the same issue.
I could workaround this by saving the id and the token to a cookie each in the subscription to the authState.
Once I have them in cookies, I just add the jwt as Bearer to every message I have to my server and it is authenticated.
And also connected everything related to my state with these cookies instead of a variable in the memory.

this way your FE session stays, after refreshing the page the variable gets nulled out, but you have everything you need amongst your cookies (or localStorage, depending on where do you store the user data)

I have another problem with this solution though I couldn't find a solution for:
I cannot call refreshAuthToken() after a page refresh, as socialLoginService doesn't use my cookies, but the cleared variable, and it causes a nullptr exception in the social-login library code.... also when I don't do any refresh but call refreshAuthToken() it sets the same jwt as before, so I cannot extend the expiration date.

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

2 participants