Problem/Motivation
When is used in combination with JSON API it's not possible see the choices labels querying the services, it's require the "administer polls" permission.
Proposed resolution
After view the module code I think that is necessary a PollChoiseAccessControlHandler class.
How a walkaround I implement a hook_entity_access in a custom module:
/**
* Allow view choices to users with permission 'access polls'.
*
* Implements hook_poll_choice_access().
*/
function MYMODULE_poll_choice_access(EntityInterface $entity, $operation, AccountInterface $account) {
switch ($operation) {
case "view":
$access_result = AccessResult::allowedIfHasPermission($account, 'access polls');
break;
}
return $access_result;
}
Remaining tasks
Write the access handler.
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Comments
Comment #2
edysmpAdding the access handler.
Comment #3
davidwhthomas commentedThanks for this patch. Tested and working.
Comment #4
davidwhthomas commentedComment #5
bramdriesenHappy to commit this, but this would require a merge request for 2.0.x as well.
Comment #9
bramdriesen