Answer the question
In order to leave comments, you need to log in
How to solve the problem with roles and accesses?
Good day!
Help me solve the problem))))
There is a site - back on Laravel, Front on Vue + Vuex, on which all the action takes place after authorization.
The main roles are admin and users.
Adding, editing, deleting all there is done by one role - admin
Users only edit the profile.
But further users must be divided into three or more entities in order to open different sections of the site. At the same time, these are simply accesses to pages, the visibility of links to these pages, etc. - they don't need to edit or create/delete anything there... I
thought to do it through Laravel Passport - Osprey Tokens for admin and users.
And here's how on the back / front for users to open / close different accesses?
Answer the question
In order to leave comments, you need to log in
Spatie Laravel-permission allows you to separate roles / accesses far and wide.
On the backend, you definitely need to check the rights for each action. There are many ready-made solutions for RBAC in Laravel, all converge to approximately the same scheme: there are roles, each has rights, each user belongs to some role / roles.
In the frontend - just load the list of rights that the user has from the server, save it in vuex. Write a simple getter (can, for example) that checks if this list contains a particular right. And then something like v-if="can('some-permission')"
I would do this
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question