laravelvue.jssingle-page-applicationlaravel-authenticationcartalyst-sentinel

how to use cartalyst sentinel permission check in laravel vue spa?


I am building a SPA with laravel and Vue js. For authentication, I have used cartalyst/sentinel package. I am facing a problem to implement permission check in frontend. In the backend I have checked for the permission with Sentinel::hasAccess() function. But in the frontend, I don't have any idea how can I check for permission. As I am using Vue SPA but they don't provide any helper function for SPA frontend.


Solution

  • You could return an array with all the permissions and save it in your vue state and then to verify a permission you could do the following:

    <button v-if="permisions['user.delete']" >delete user</button>