Skip to content
Snippets Groups Projects
Commit 69fea46e authored by Stephan Zeidler's avatar Stephan Zeidler Committed by Roberto Ornelas
Browse files

Issue #3088689 by szeidler, henrikakselsen: Administer Gutenberg Permission required to use editor

parent f35901b8
No related branches found
Tags 8.x-2.0-alpha4
No related merge requests found
......@@ -53,6 +53,8 @@ CONFIGURATION
* Then go to any content type edit page and enable *Gutenberg Experience*.
* Assign the `use gutenberg` permission and access to the "Gutenberg" text format to all desired user roles.
DEVELOPMENT
-----------
......
......@@ -124,6 +124,19 @@ function gutenberg_update_8202(&$sandbox) {
}
}
/**
* Rename Gutenberg permission name to "Use gutenberg".
*/
function gutenberg_update_8203(&$sandbox) {
// Load roles with the legacy gutenberg administer role.
$roles = user_roles(FALSE, 'gutenberg administer');
foreach ($roles as $role) {
$role->revokePermission('gutenberg administer');
$role->grantPermission('use gutenberg');
$role->save();
}
}
/**
* Implements hook_uninstall().
*/
......
'gutenberg administer':
title: 'Administer Gutenberg'
use gutenberg:
title: 'Use Gutenberg experience'
description: 'Access to any Gutenberg related actions'
......@@ -12,7 +12,7 @@ gutenberg.media_edit_form:
file:
type: entity:media
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
gutenberg.media.upload:
path: '/editor/media/upload/{editor}'
......@@ -21,7 +21,7 @@ gutenberg.media.upload:
methods: 'POST'
requirements:
_entity_access: 'editor.use'
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
gutenberg.media.load:
path: '/editor/media/load/{file}'
......@@ -32,7 +32,7 @@ gutenberg.media.load:
type: entity:file
methods: 'GET'
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
gutenberg.media.load_media:
path: '/editor/media/load-media/{media}'
......@@ -40,7 +40,7 @@ gutenberg.media.load_media:
_controller: '\Drupal\gutenberg\Controller\MediaController::loadMedia'
methods: 'GET'
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
gutenberg.media.dialog:
path: '/editor/media/dialog'
......@@ -48,7 +48,7 @@ gutenberg.media.dialog:
_controller: '\Drupal\gutenberg\Controller\MediaController::dialog'
methods: 'GET'
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
gutenberg.media.render:
path: '/editor/media/render/{media}'
......@@ -56,7 +56,7 @@ gutenberg.media.render:
_controller: '\Drupal\gutenberg\Controller\MediaController::render'
methods: 'GET'
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
gutenberg.blocks.load:
path: '/editor/blocks/load_by_type/{content_type}'
......@@ -65,7 +65,7 @@ gutenberg.blocks.load:
content_type: 'none'
methods: 'GET'
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
gutenberg.blocks.load_single:
path: '/editor/blocks/load/{plugin_id}'
......@@ -76,7 +76,7 @@ gutenberg.blocks.load_single:
# type: entity:block
methods: 'GET'
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
gutenberg.reusable_blocks.create:
path: '/editor/reusable-blocks'
......@@ -84,7 +84,7 @@ gutenberg.reusable_blocks.create:
_controller: '\Drupal\gutenberg\Controller\ReusableBlocksController::save'
methods: 'POST'
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
gutenberg.reusable_blocks.update:
path: '/editor/reusable-blocks/{block_id}'
......@@ -108,7 +108,7 @@ gutenberg.reusable_blocks.load:
_controller: '\Drupal\gutenberg\Controller\ReusableBlocksController::load'
methods: 'GET'
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
gutenberg.reusable_blocks.load_single:
path: '/editor/reusable-blocks/{block_id}'
......@@ -124,7 +124,7 @@ gutenberg.oembed:
_controller: '\Drupal\gutenberg\Controller\OEmbedProxyUrlController::request'
methods: 'GET'
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
gutenberg.content.search:
path: '/editor/search'
......@@ -132,7 +132,7 @@ gutenberg.content.search:
_controller: '\Drupal\gutenberg\Controller\SearchController::search'
methods: 'GET'
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
gutenberg.media.search:
path: '/editor/media/search/{type}/{search}'
......@@ -140,7 +140,7 @@ gutenberg.media.search:
_controller: '\Drupal\gutenberg\Controller\MediaController::search'
methods: 'GET'
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
gutenberg.media.update_data:
path: '/editor/media/update_data/{fid}'
......@@ -148,7 +148,7 @@ gutenberg.media.update_data:
_controller: '\Drupal\gutenberg\Controller\MediaController::updateData'
methods: 'POST'
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
gutenberg.media.autocomplete:
path: '/editor/media/autocomplete'
......@@ -156,5 +156,5 @@ gutenberg.media.autocomplete:
_controller: '\Drupal\gutenberg\Controller\MediaController::autocomplete'
methods: 'GET'
requirements:
_permission: 'gutenberg administer'
_permission: 'use gutenberg'
_format: json
......@@ -157,7 +157,7 @@ class ReusableBlocksController extends ControllerBase {
$block = BlockContent::load($block_id);
// Check if the user has the proper permissions.
$access = AccessResult::allowedIfHasPermission($account, 'gutenberg administer');
$access = AccessResult::allowedIfHasPermission($account, 'use gutenberg');
if ($access->isAllowed()) {
// Only throw the 404 if the user is allowed to access the route.
// Avoids anonymous users scanning for a block's existence.
......
......@@ -19,7 +19,7 @@ class MediaLibraryGutenbergOpener implements MediaLibraryOpenerInterface {
* {@inheritdoc}
*/
public function checkAccess(MediaLibraryState $state, AccountInterface $account) {
return AccessResult::allowedIf($account->hasPermission('gutenberg administer'));
return AccessResult::allowedIf($account->hasPermission('use gutenberg'));
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment