Skip to content
Snippets Groups Projects
Commit b3a42467 authored by Kevin Paxman's avatar Kevin Paxman
Browse files

Merge branch 'feature/ISTWCMS-5333-ebremner-content-moderation-access' into '1.0.x'

ISTWCMS-5333: ensuring that only users with access can unpublish content

See merge request !205
parents 8662960a 69656513
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 { ...@@ -76,9 +76,27 @@ class UwContentModerationForm extends ConfirmFormBase {
* A AccessResult object. * A AccessResult object.
*/ */
public function access(int $nid, AccountInterface $account): AccessResult { 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')) { if (UWService::nodeIsHomePage($nid) && !$account->hasPermission('bypass home page protection')) {
return AccessResult::forbidden(); 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(); return AccessResult::allowed();
} }
......
...@@ -12,7 +12,6 @@ uw_content_moderation.form: ...@@ -12,7 +12,6 @@ uw_content_moderation.form:
_form: '\Drupal\uw_cfg_common\Form\UwContentModerationForm' _form: '\Drupal\uw_cfg_common\Form\UwContentModerationForm'
requirements: requirements:
_custom_access: '\Drupal\uw_cfg_common\Form\UwContentModerationForm::access' _custom_access: '\Drupal\uw_cfg_common\Form\UwContentModerationForm::access'
_permission: 'access content'
uw_cfg_common.analytics_ownership.form: uw_cfg_common.analytics_ownership.form:
path: '/admin/config/google_analytics_settings' path: '/admin/config/google_analytics_settings'
defaults: 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