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

CommentFileSizeAuthor
#2 2995307-2.patch1.51 KBedysmp

Issue fork poll-2995307

Command icon 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

psf_ created an issue. See original summary.

edysmp’s picture

Status: Active » Needs review
StatusFileSize
new1.51 KB

Adding the access handler.

davidwhthomas’s picture

Thanks for this patch. Tested and working.

davidwhthomas’s picture

Status: Needs review » Reviewed & tested by the community
bramdriesen’s picture

Version: 8.x-1.2 » 2.0.x-dev
Status: Reviewed & tested by the community » Needs work

Happy to commit this, but this would require a merge request for 2.0.x as well.

  • BramDriesen committed e5efd3b6 on 2.0.x
    Issue #2995307 by edysmp, psf_, davidwhthomas, BramDriesen: Poll choice...

  • 7b0e4125 committed on 8.x-1.x
    Issue #2995307 by BramDriesen, edysmp, davidwhthomas, psf_: Poll choice...
bramdriesen’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.