Closed yamenarahman closed 4 years ago
Hi @yamenarahman! Thank you very much for your enthusiasm for improving the package 🎉. Have you tried the v-role-or-permission
directive?
Check for role or permission:
<button v-role-or-permission="'super|add articles'">Add Article</button>
Tell me if this can solve the problem.
Hi @williamcruzme First of all great work man! Yes, I've tried this directive but I think it's not applicable for multiple permissions, right? So I guess the following code doesn't work:
<button v-role-or-permission="'super|Edit article|Edit any article'">Edit Article</button>
How to get around these?
You have an excellent point, I think if I convert multiple permissions/roles to comma separated, it could work.
<button v-role-or-permission="'super|add articles,edit articles'">Manage Articles</button>
What do you think @yamenarahman?
I tried it:
<button v-role-or-permission="'super|Edit article,Edit any article'">Edit Article</button>
But this checks all permissions to be true not 'OR'.
No no @yamenarahman, its a suggestion of a new feature.
Sounds great! also how about renaming the directive to v-role:or-permissions:any
and v-role:or-permissions:all
.
I'm willing to submit a PR would you suggest me how to begin adding these features?
If you like, create a PR and we will implement it 😎
Hi @williamcruzme
The idea of a super-admin was to avoid for having to check access every time throughout the app, putting it in a v-role-or-permission
is still counterproductive. I think @yamenarahman first idea is still applicable for enhancement so that we could set a super-admin globally.
Vue.use(LaravelPermissions, { persistent: true, superRole: 'admin' });
@marielsabornido @yamenarahman Thank you very much for the feedback, I'll work on this issue and others. Something big is coming! 🎉, and it will be compatible with Vue 3 😎
The feature has been successfully added. Thanks for the input! 🙌
e69f26a26dbbbb5e6b5a4434ac5e69c7ca8af489
@williamcruzme Looks amazing man. Thanks for the plugin by the way, was having issues applying permissions in vue, this was a godsend.
Like Laravel; we can grant access to all permissions for user by set
Gate::before()
method.How can we implement it on the front end side? maybe setting a super role during registering the component like:
Vue.use(LaravelPermissions, { persistent: true, superRole: 'admin' });
so that meens if the auth user has role 'admin' he could pass all permissions.
I'm willing to implement this in a PR but give me a little guidance please. Thanks.