Skip to content
Snippets Groups Projects
Commit aa8f93aa authored by Lily Yan's avatar Lily Yan
Browse files

Merge branch 'feature/ISTWCMS-5190-ibiki-dashboard-access' into '1.0.x'

ISTWCMS-5190: Using access denied instead of 404 when user has no edit permissions.

See merge request !176
parents c25db734 38e1bade
No related branches found
No related tags found
1 merge request!176ISTWCMS-5190: Using access denied instead of 404 when user has no edit permissions.
...@@ -8,7 +8,6 @@ use Drupal\Core\Routing\RouteMatchInterface; ...@@ -8,7 +8,6 @@ use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\menu_admin_per_menu\Access\MenuAdminPerMenuAccess; use Drupal\menu_admin_per_menu\Access\MenuAdminPerMenuAccess;
use Drupal\uw_cfg_common\Service\UWService; use Drupal\uw_cfg_common\Service\UWService;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* Checks access for displaying configuration translation page. * Checks access for displaying configuration translation page.
...@@ -65,19 +64,17 @@ class UwNodeAccessCheck implements AccessInterface { ...@@ -65,19 +64,17 @@ class UwNodeAccessCheck implements AccessInterface {
$node = $route_match->getParameter('node'); $node = $route_match->getParameter('node');
// Check if this is a sidebar content type and if the user has permission // Check if this is a sidebar content type and if the user has permission
// to edit the content type. We want to throw a 404 (NotFoundHttpException) // to edit the content type. Return access denied when user has no edit
// if they do not have access. This is the case when a user is not logged // permission.
// in, and when they do not have permission to edit it.
if ($node && $node->bundle() == 'uw_ct_sidebar' && !$account->hasPermission('edit any uw_ct_sidebar content')) { if ($node && $node->bundle() == 'uw_ct_sidebar' && !$account->hasPermission('edit any uw_ct_sidebar content')) {
throw new NotFoundHttpException(); return AccessResult::forbidden();
} }
// Check if this is a sidebar content type and if the user has permission // Check if this is a sidebar content type and if the user has permission
// to edit the content type. We want to throw a 404 (NotFoundHttpException) // to edit the content type. Return access denied when user has no edit
// if they do not have access. This is the case when a user is not logged // permission.
// in, and when they do not have permission to edit it.
if ($node && $node->bundle() == 'uw_ct_site_footer' && !$account->hasPermission('edit any uw_ct_site_footer content')) { if ($node && $node->bundle() == 'uw_ct_site_footer' && !$account->hasPermission('edit any uw_ct_site_footer content')) {
throw new NotFoundHttpException(); return AccessResult::forbidden();
} }
// We have to return some type of access, so we are going to return // We have to return some type of access, so we are going to return
......
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