feathersjs-ecosystem / feathers-permissions

Simple role and service method permissions for Feathers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use checkPermissions with nested field

skaptox opened this issue · comments

Steps to reproduce

Hello. I'm starting to use feathers. I don't know how to use checkPermissions with nested permissions without add permissions field to root of my model.

Expected behavior

{
            "_id": "5cb3bb8115afab14a74e5ad3",
            "email": "test@test.com",
            "roleId": "5cb3af204ddf5e03c15868a9",
            "_include": [
                "roles"
            ],
            "roles": {
                "_id": "5cb3af204ddf5e03c15868a9"
                "permissions": [
                    "documents-types:*",
                ],
                "name": "documents-types admin",
            }
}

User hook

after: {
    all: [ 
      populate({ schema: userRoleSchema })
      ...
    ]

Documents-types hooks

before: {
    all: [checkPermissions({
      roles: [ 'documents-types' ],
      field: 'roles.permissions',
    })],
   ...
}

Actual behavior

It doesn't work. I had to add this hook to user to extract the permissions.

    after: {
    ...
    get: [(context) => { context.result.permissions = context.result.roles.permissions; return context;}],

System configuration

feathers --version 3.9.0
"feathers-hooks-common": "^4.20.7",
"feathers-mongoose": "^7.3.2",
"feathers-permissions": "^0.2.1",

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Apologies if the issue could not be resolved. FeathersJS ecosystem modules are community maintained so there may be a chance that there isn't anybody available to address the issue at the moment. For other ways to get help see here.