diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index b779d19..d3a1411 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -178,11 +178,12 @@ public function commentPermalink(Request $request, CommentInterface $comment) { public function getReplyForm(Request $request, NodeInterface $node, $pid = NULL) { $uri = $node->uri(); $build = array(); + $account = $request->attributes->get('account'); drupal_set_title(t('Add new comment')); // Check if the user has the proper permissions. - if (!user_access('post comments')) { + if (!$account->hasPermission('post comments')) { drupal_set_message(t('You are not authorized to post comments.'), 'error'); return new RedirectResponse($this->urlGenerator->generateFromPath($uri['path'], array('absolute' => TRUE))); } @@ -197,7 +198,7 @@ public function getReplyForm(Request $request, NodeInterface $node, $pid = NULL) // $pid indicates that this is a reply to a comment. if ($pid) { // Check if the user has the proper permissions. - if (!user_access('access comments')) { + if (!$account->hasPermission('access comments')) { drupal_set_message(t('You are not authorized to view comments.'), 'error'); return new RedirectResponse($this->urlGenerator->generateFromPath($uri['path'], array('absolute' => TRUE))); } @@ -213,7 +214,7 @@ public function getReplyForm(Request $request, NodeInterface $node, $pid = NULL) } // The comment is in response to a node. - elseif (user_access('access content')) { + elseif ($account->hasPermission('access content')) { // Display the node. $build['comment_node'] = $this->entityManager->getRenderController('node')->view($node); }