feathers-permissions icon indicating copy to clipboard operation
feathers-permissions copied to clipboard

Add a client-side counterpart

Open Alfredo-Delgado opened this issue 6 years ago • 0 comments

After integrating feathers-permissions (backed by PostgreSQL), I want to make it possible for UI devs to use the same logic.

contrived example: class="'userInstance.can('item:remove') || 'disabled'"

I'd like to move https://github.com/feathersjs-ecosystem/feathers-permissions/blob/master/lib/index.js#L39-L60 into its own function so that it can be used by the existing hook and a more generic implementation.

e.g.

permissionsContain(permissions, roles, method);

checkPermission(permission, permissions);
checkPermission('item:get', [ 'item:*' ]);

FrontendUserModel.prototype.can = function(permission) {
  return checkPermission(permission, this.permissions);
}

Alfredo-Delgado avatar Aug 22 '18 21:08 Alfredo-Delgado