Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_cfg_common
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_cfg_common
Commits
69656513
Commit
69656513
authored
3 years ago
by
Eric Bremner
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-5333: better access control for content moderation form
parent
990fb540
No related branches found
No related tags found
1 merge request
!205
ISTWCMS-5333: ensuring that only users with access can unpublish content
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Form/UwContentModerationForm.php
+18
-0
18 additions, 0 deletions
src/Form/UwContentModerationForm.php
uw_cfg_common.routing.yml
+0
-1
0 additions, 1 deletion
uw_cfg_common.routing.yml
with
18 additions
and
1 deletion
src/Form/UwContentModerationForm.php
+
18
−
0
View file @
69656513
...
...
@@ -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
();
}
...
...
This diff is collapsed.
Click to expand it.
uw_cfg_common.routing.yml
+
0
−
1
View file @
69656513
...
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment