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

How to determine the login status in React (javascript). #196

Closed
ghost opened this issue Dec 18, 2020 · 1 comment
Closed

How to determine the login status in React (javascript). #196

ghost opened this issue Dec 18, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 18, 2020

I want to use React (javascript) to determine login status, but I can't access cookies from javascript due to http-only cookies.

I thought of actually making an HTTP request and using the response status value to determine the status, but I get a 401 error message in the browser developer console.

Should I create a cookie or local storage with the same expiration date and use that value to determine the status?

How can I determine the login status?

@Luctia
Copy link

Luctia commented Dec 21, 2020

I think the method you proposed is fine, but a better way would be to call /token/verify. However, as I mentioned in #191 you can't access this endpoint if you use http-only. I guess for now the only option is what you mentioned.

@ghost ghost closed this as completed Jan 2, 2021
This issue was closed.
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

1 participant