Reputation: 15
I am using local storage for my website to keep user logged in. On loading of page i'm checking if there exists a token in local storage, however, before login if i put a random value in local storage with key "auth-token" then after refreshing, the page will act in a state where user has logged in. how may i check if the token is legit and not some random value, before loading of page?
Upvotes: 1
Views: 722
Reputation: 4558
When you use your JWT to call a service it will return unauthorized access so therefore you can logout the user. That’s how you can know if it’s a valid token.
Upvotes: 3