Restricted pages as per user permission - vuejs / laravel

1

How to allow or prevent a user from accessing a particular page? Let's say the user is not allowed to access the finanças page. Where do I report the access permissions on this page? Remember that these permissions will be set to localStorage from a backend in laravel.

    
asked by anonymous 19.01.2018 / 13:22

1 answer

0

You can use Router beforeEach or another equivalent if you are using another router to validate all protected routes, as documentation , to validate the token and permissions on the backend and receive a simple response from the backend or not authorized for the frontend to continue navigation to the route or not.

You can also define a beforeEnter method to validate a specific route:

const router = new VueRouter({
  routes: [
    {
      path: '/foo',
      component: Foo,
      beforeEnter: (to, from, next) => {
        // ...
      }
    }
  ]
})
    
19.01.2018 / 14:12