简体   繁体   English

路由保护VUE-路由器

[英]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? 我在vue上有管理仪表板,我需要知道通过检查vuex吸气器的“ isLoggedIn”标志来保护此路由是否正确? This flag changing after success login to "true" right after client gets admin JWT from backend. 在客户端从后端获取管理JWT之后,成功登录后此标志将更改为“ true”。 If someone trying to get "/dashboard" route without that flag, vue-router forward him to "/login" route. 如果有人试图获取不带该标志的“ / dashboard”路由,则vue-router将其转发到“ / login”路由。 But I still not sure about that solution: is it possible to change this flag direct from client or from vue tools? 但是我仍然不确定该解决方案:是否可以直接从客户端或vue工具更改此标志?

Yes, it possible. 是的,有可能。 A client with vue devtool can change the variable isLoggedIn. 具有vue devtool的客户端可以更改变量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. 当有人尝试进入管理页面时,向后端发送请求,以检查该用户是否以管理员身份登录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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