This is a basic "guard" that you can use with simple permissions
This is still work in progress, but the basic works.
There will be a vue directive guard too in the near future.
npm i @mr_chick/vue_guardimport guard from '@mr_chick/vue_guard'Vue.use(guard, {'store': store});
this.$guard.allow('i-can-do-this');
You can add an Instance and an ID to the allow / disallow, and it will be a more specific way of setting permission
this.$guard.allow('i-can-do-this','User','12')
That means, only the can('i-can-do-this', 'User', '12') will return true, anything else, will allow false.
this.$guard.disallow('i-can-do-this')
Same as allow, you can pass the optional Instance and ID if you need more granual permissions
You use disallow when you use a specific permission, for a specific Instance / ID, but you still want a global permission
For ex
this.$guard.allow('i-can-do-this')
this.$guard.disallow('i-can-do-this', 'User', 12)
will return false only for this.$guard.can('i-can-do-this', 'User', 12)
this.$guard.can('i-can-do-this', 'User', {any_other_id}) or this.$guard.can('i-can-do-this', { Any other instance }) or this.$guard.can('i-can-do-this') will return true
this.$guard.can('i-can-do-this') returns true if permission exists, false if not
You can pass the optional parameters Instance and ID for more granual check
this.$guard.can('permission')
this.$guard.can('permission', 'Instance')
this.$guard.can('permission', 'Instance', 'ID')
this.$guard.cannot('permission', 'Instance', 'ID')
this.$guard.cant('permission', 'Instance', 'ID') (alias for cannot)