0

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.

  • Its not gonna work like that you should pass array of permission from backend and handle it in frontend – Desmond_ Jun 09 '20 at 13:09
  • But it will slow the entire system to check each permission validity from backend. I am looking for something helper function like vuei18 with laravel lang class – Fahim Hasan Jun 09 '20 at 13:34

1 Answers1

0

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>
Itamar Garcia
  • 882
  • 10
  • 17
  • That doesn't sound so good when you have hundreds of permissions, and when the permissions can be inherited from roles. – Hkan Dec 13 '20 at 19:06