Tarun Parmar
Tarun Parmar

Reputation: 15

how to check if J.W.T token in local storage is legit?

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

Answers (1)

Dilshan Liyanage
Dilshan Liyanage

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

Related Questions