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

Question about list_permissions in `show_items` endpoint

Open ymwdalex opened this issue 4 years ago • 1 comments

Hi @holgi ,

First, thanks for sharing this package!

When this is the response of show_items endpoint in the example. I login with alice, and I don't understand why view is false for both item 1 and 2. Thanks!

[
  {
    "items": {
      "1": {
        "name": "Stilton",
        "owner": "bob"
      },
      "2": {
        "name": "Danish Blue",
        "owner": "alice"
      }
    },
    "available_permissions": {
      "1": {
        "use": false,
        "view": false
      },
      "2": {
        "use": true,
        "view": false
      }
    }
  }
]

ymwdalex avatar Dec 15 '20 22:12 ymwdalex

Hi @holgi , I think it should be get_active_principals in depends instead of get_current_user.

async def show_items(
    ilr: ItemListResource = Permission("view", ItemListResource),
    user=Depends(get_current_user),
):

ymwdalex avatar Dec 18 '20 10:12 ymwdalex