We have two permissions that look like the overriding admin permission:

- administer licenses: defined in our yml
- administer commerce_license: provided by Entity API in the permissions handler

The first should be removed, and the entity's admin permission changed to the second.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

malaynayak’s picture

Hi @joachim,

Please review the patch.

emartoni’s picture

Status: Active » Reviewed & tested by the community

Works for me!

joachim’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for working on this!

However, I'm afraid I was a bit slap-dash in writing the summary -- I didn't think anyone would get to it so quickly!

> - administer commerce_license: provided by Entity API in the permissions handler

I think the permission Entity API provides is of the form 'verb ENTITYTYPE entities' -- you'd need to check the code.

malaynayak’s picture

Hi @joachim,

. I have checked the Entity API and it provides the default administer permission in the form of administer {$entity_type_id}. Referring code written in Drupal\entity\EntityPermissionProviderBase class I think, what we have done is correct. Please have a look on below code.

/**
 * {@inheritdoc}
 */
 public function buildPermissions(EntityTypeInterface $entity_type) {
   $entity_type_id = $entity_type->id(); can confirm that
   $has_owner = $entity_type->entityClassImplements(EntityOwnerInterface::class);
   $plural_label = $entity_type->getPluralLabel();

   $permissions = [];
   $permissions["administer {$entity_type_id}"] = [
     'title' => $this->t('Administer @type', ['@type' => $plural_label]),
     'restrict access' => TRUE,
   ];
.
.
.
malaynayak’s picture

Status: Needs work » Needs review

  • joachim committed 1428117 on 8.x-2.x authored by malaynayak
    Issue #2945067 by malaynayak: Removed superfluous 'administer licenses'...
joachim’s picture

Status: Needs review » Fixed

You're absolutely right. Thanks for checking that, and thanks again for the patch.

Committed!

emartoni’s picture

Status: Fixed » Closed (fixed)

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