iFahd Dev
iFahd Dev

Reputation: 71

vue.js update current user data from api when change route?

im new in vuejs and i build small control panel and i have roles and permissions.

when user login i store data in local storage with user data and he roles and permissions

but when the admin attach or change role or permission for any user

not update in that user if he login even he logout and login again

my solution is get current user every time from api when route change!

i put my call function in app.js

store.dispatch('users/getUser');

is that good solution ?

Upvotes: 0

Views: 708

Answers (1)

Damil
Damil

Reputation: 97

I would not store profile and permissions in localStorage as user could inspect it and modify it.

I think you should store user id encrypted and in each route change validate if he as permission for the desired page or action.

So essentially yes but don’t forget about security.

Upvotes: 1

Related Questions