williamcruzme / vue-gates

πŸ”’ A Vue.js & Nuxt.js plugin that allows you to use roles and permissions in your components or DOM elements, also compatible as middleware and methods.

Home Page:https://williamcruzme.github.io/vue-gates/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How about a super user?

yamenarahman opened this issue Β· comments

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.

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! πŸ™Œ

e69f26a

@williamcruzme Looks amazing man. Thanks for the plugin by the way, was having issues applying permissions in vue, this was a godsend.