Problem/Motivation
With Drupal 7, it was possible to define in Views a page with several displays, having all the same URL. By ordering the displays in descending order of access level (Administrator first, Anonymous last), it is possible to have different renderings depending on the role of the logged in user. This allowed for a single menu entry that displayed only the data to which the user is entitled. This doesn't seem to work anymore in Drupal 8 and 9.
Steps to reproduce
- Create 2 users:
- user1 with the profile Content editor
- user2 with the authenticated user profile
- Create a view _test
- Duplicate the display
- Rename first display to Page user1 and set role access (for this display only) to Content Editor
- Rename second display to Page user2 and set role access (for this display only) to Authenticated user
- Login as user1 and go to /test
- (The view is correctly displayed)
- Logout and login as user2 and go to /test
- (Access is denied)
- Logout, login as admin and disable display Page user1, save and login as user2
- (The view (Page user2) is displayed)
Proposed resolution
During checkAccess, each display must be checked, not only the first one and the route updated
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | Duplicate Display.png | 138.38 KB | andregp |
Issue fork drupal-3255889
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
Comment #2
andregp commentedI followed the steps above and this problem also happens on version 9.4.x (as you can see on the images attached), I'll try to work on a patch.
Comment #3
andregp commentedComment #4
andregp commentedSorry for the files on #3. Please ignore them.
Comment #5
andregp commentedComment #6
andregp commentedI was able to reproduce the error, but wasn't able to find a solution so I'm unassigning myself.
Comment #7
lendudeSee the explanation in #2659786: View having multiple page displays on same path does not respect different access rights, this changed between D7 and D8 because the routing in D8 is completely different.
The other issue was closed as 'work as designed', but was also suggested it could be moved to a feature request, which is what I will do for now.