Currently this module doesn't work with the 2.x branch of https://www.drupal.org/project/jsonapi. I'm trying to use the two together currently and have found that the issue is around the customer access check event dispatcher. A small fix appears to resolve the issue, but, tbh I haven't had time to review this completely. I'm interested in your thoughts. I'm going to add a ticket in our project board to go back and review this code to make sure it's not breaking anything else.
Issue fork permissions_by_term-3032557
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
kurtfoster commentedHere's the patch.
Comment #3
damontgomery commentedI had a similar issue. I'll attach my patch below.
Use case:
Use a term reference field on a node. Configure a term to provide access to a role. Configure this module with `Permissions mode`.
Assign the `access content` permission to the role.
Access a list of that node type at /jsonapi/node/article for example.
Expected:
Only the nodes with that term are shown.
Actual:
All nodes are shown.
----
Viewing things through the browser works as expected, only nodes with the terms can be seen.
I've narrowed it down to this code:
This code as described throws a message which forwards the user in the browser. But... that doesn't apply to the API endpoint and thus it does nothing and the default `access content` permission says we can access the content. If I remove that permission, I cannot access content at all on the browser or through the API.
I expect node_access hooks to return an AccessResult object. Why use this redirect pattern instead of the AccessResult object?
The patch I worked on is similar to that above, but gets rid of the dispatcher (well, doesn't call it at this point). I swap the message for the AccessResult object which worked for us. If this is a more specific use case, people can use the patch in a custom module.
Comment #4
richardgaunt commentedSorry ignore.
Comment #5
richardgaunt commentedReroll #2 patch for module version 8.x-2.33
Comment #6
bstan commentedRe-roll #2 patch for 3.1.x
Comment #7
bstan commentedFixed patch with latest in 3.1.x-dev
Comment #8
bstan commentedMissed removing the `void` 🤦♂️
Comment #9
jepster_Thanks for your contribution. I've released this with version 3.1.41. See: https://www.drupal.org/project/permissions_by_term/releases/3.1.41