Closed (fixed)
Project:
Administer Users by Role
Version:
8.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Nov 2016 at 16:09 UTC
Updated:
10 Apr 2017 at 15:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
vtcore commentedI know this is related with #2773645: Allow hook_entity_field_access() to grant field-level access to User fields: 'forbidden' -> 'neutral'. The patch provided is a workaround for user fields. Also it alters the access of the "user_role" entity in order to show role names in admin/people.
Comment #3
adamps commented@vtcore Thanks for the issue and patch. I am reluctant to commit a workaround patch until we have tried really hard to get the core fix applied. However it certainly is useful to have the patch available for anyone would like to use it.
As a starting point, please can you review and test my patch in #2773645: Allow hook_entity_field_access() to grant field-level access to User fields: 'forbidden' -> 'neutral', then mark it as RTBC, with an endorsement for how it is an important fix?
You say your patch "also alters the access". Please can you explain more? Do you mean that your patch provides some extra function that the patch in #2773645: Allow hook_entity_field_access() to grant field-level access to User fields: 'forbidden' -> 'neutral' does not? If so, please can you separate out the parts of the patch that are a workaround and the parts that ought to be committed even if the core patch gets applied?
Comment #4
vtcore commentedSorry about the quick and dirty patch. The patch at #2773645: Allow hook_entity_field_access() to grant field-level access to User fields: 'forbidden' -> 'neutral' works fine for the field's access. However the role names are not shown (see attached screenshot). The first part of the patch is for that
function administerusersbyrole_user_role_access(). I'll split the patch in two:I marked the core issue as RTBC.
Comment #5
vtcore commentedPatch for roles access.
Implements
hook_ENTITY_TYPE_accessfor theuser_roleentity type. If the operation is 'view' we check the permission 'access users overview' provided by administerusersbyrole.The default core permission that is checked is 'administer permissions' which is for viewing, adding, editing and deleting roles, and we don't want to give that to our "low-privilege" admins just to be able to see which role is assigned to a user.
Comment #6
vtcore commentedWorkaround for #2773645: Allow hook_entity_field_access() to grant field-level access to User fields: 'forbidden' -> 'neutral'
Implements
hook_entity_field_access_alterand changes the :default AccessResult if administerusersbyrole allowed it.Comment #8
adamps commentedCommitted the patch for show role names in admin/people, thanks.
Comment #9
adamps commentedRemainder of issue for missing fields is marked as postponed pending a determined attempt to get the fix applied to core.
Comment #10
adamps commentedThe core issue #2773645: Allow hook_entity_field_access() to grant field-level access to User fields: 'forbidden' -> 'neutral' is now marked as "needs tests". If anyone can help with that, please go ahead and upload a patch.
Comment #11
nyariv commentedThe commit in #7 does not work for me. It seems the hook does not get called at all for non admins.
Comment #12
adamps commented@nyariv It's still working fine for me. Please check #2807021: Drupal 8 roadmap - did you definitely apply the patch for #2773645: Allow hook_entity_field_access() to grant field-level access to User fields: 'forbidden' -> 'neutral'?
Comment #13
nyariv commented@AdamPS I enabled administerusersbyrole_hack and it did not help. If it is possible to apply a workaround through that module, it would be preferable to applying a patch to core, at least as a temporary solution.
Comment #14
adamps commentedRight now the "hack" module does not help with #2773645: Allow hook_entity_field_access() to grant field-level access to User fields: 'forbidden' -> 'neutral' but I agree that's a good idea.
Comment #15
nyariv commented@AdamPS Is there a code snippet I can use until it is committed?Nevermind, I didn't notice #6.Comment #16
nyariv commentedWhen filtering for a user name in the user management page you get 'page not found' if you do not have admin permissions. All other filters work. This applies to both #6 patch and core patch.
Comment #17
adamps commented@nyariv thanks for the report please can you open a new issue?
Comment #18
adamps commentedComment #19
adamps commented@nyariv thanks I see your new issue for #16. Please can you also raise one for #13? It is definitely helpful to me that we are getting back to one issue for each bug / patch / commit.
I have marked this issue as fixed because #5 has been committed.
Comment #20
nyariv commentedAdded issue #2864386: Apply core user field access bug workaround.