Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kevinwakhisi's avatar

Vue Router Navigation Guards

I've successfully exposed my permissions via spatie/permissions and also used the v-if directive to show components if you are authorized . Now my issue is how can i also guard my routes in the vue router (routes.js) supposing a particular individual has no rights to view a certain page despite typing the URL in the address bar (in this case probably they were termed unauthorized). I've used this script below to expose it to my vue models

 <script>
         window.user =@json([
             'user' =>auth()->user(),
             'roles' =>auth()->user()->roles,
             'permissions' =>auth()->user()->getAllPermissions()
         ])
  </script>
0 likes
1 reply

Please or to participate in this conversation.