Skip to content
Snippets Groups Projects
Commit 69656513 authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-5333: better access control for content moderation form

parent 990fb540
No related branches found
No related tags found
1 merge request!205ISTWCMS-5333: ensuring that only users with access can unpublish content
......@@ -76,9 +76,27 @@ class UwContentModerationForm extends ConfirmFormBase {
* A AccessResult object.
*/
public function access(int $nid, AccountInterface $account): AccessResult {
// Ensure that anonymous users can not
// access this form.
if ($account->isAnonymous()) {
return AccessResult::forbidden();
}
// Ensure that home page access is respected.
if (UWService::nodeIsHomePage($nid) && !$account->hasPermission('bypass home page protection')) {
return AccessResult::forbidden();
}
// Get the node.
$node = $this->entityTypeManager->getStorage('node')->load($nid);
// If the user does not have permission to edit the node
// forbid them from the link.
if (!$account->hasPermission('edit any ' . $node->bundle() . ' content')) {
return AccessResult::forbidden();
}
return AccessResult::allowed();
}
......
......@@ -12,7 +12,6 @@ uw_content_moderation.form:
_form: '\Drupal\uw_cfg_common\Form\UwContentModerationForm'
requirements:
_custom_access: '\Drupal\uw_cfg_common\Form\UwContentModerationForm::access'
_permission: 'access administration pages'
uw_cfg_common.analytics_ownership.form:
path: '/admin/config/google_analytics_settings'
defaults:
......
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