Closed (fixed)
Project:
Permissions by Term
Version:
8.x-2.6
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Feb 2019 at 02:35 UTC
Updated:
15 Apr 2026 at 17:40 UTC
Jump to comment: Most recent, Most recent file
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