简体   繁体   中英

Route protect vue-router

I have admin dashboard on vue and I need to know is it enouth to protect this route by checking for example "isLoggedIn" flag from vuex getters? This flag changing after success login to "true" right after client gets admin JWT from backend. If someone trying to get "/dashboard" route without that flag, vue-router forward him to "/login" route. But I still not sure about that solution: is it possible to change this flag direct from client or from vue tools?

Yes, it possible. A client with vue devtool can change the variable isLoggedIn. I would prefer to use some kind of a list in the backend which contains the logged in admins at the moment. When someone try reaching the admin page send request to the backend to check if this user logged in as admin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM