[Vuejs]-Save user authentication status in vuex state is safe Solution?

0👍

Can the user modify the vuex state in production mode?

Yes, the user can do anything to the state of the app. You can obfuscate some things, but you cannot prevent the user from inspecting or modifying the data of your app.

Save user authentication status in vuex state is safe Solution?

It is one approach, and I do recommend it especially as your app size grows it will become easier to manage shared state in your app. But I wouldn’t say it is “safe” or “unsafe”.

I can change state manually by vue dev tools thus I can enter the protected route so authentication is not working properly.

The app’s behavior can be easily circumvented as you have described. You only have complete control over the server code. If the protected route becomes accessible on the client because the user tampered with the data using dev tools, then the server should reject any requests for privileged data that the protected route requires.

Leave a comment