Poll choice access handler

Created on 27 August 2018, over 6 years ago
Updated 3 May 2024, 8 months ago

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

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇪🇸Spain psf_ Huelva

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024