Open AlexanderOpran opened 5 years ago
No one actually encountered this problem?
When the authentication check fails (401), we should also commit the purgeAuth mutation in order to clear the state.
^ Exactly what I've changed when building from this template. Because with the current repo state for e.g. when jwt token expires and your API starts sending you 401 (Unauthorized) - your front-end stays on the same page, rather than committing a purgAuth commit and pushing you to Login page.
thank guys to pointing out of this bug, I stuck in that 2 days
https://github.com/gothinkster/vue-realworld-example-app/blob/e9edd6f6148cad07b68f32d2a770e2bc7e68af14/src/store/auth.module.js#L56-L69
As it currently stands, when the JWT token expires or is invalid the user will be permanently stuck in the isAuthenticated state. You can test it for yourselves by going to https://vue-vuex-realworld.netlify.com/, log in and then delete the token from local storage or alter it a bit and then either go to a new route or refresh the page and see what happens.
I think this is a pretty serious issue.
When the authentication check fails (401), we should also commit the purgeAuth mutation in order to clear the state.