From ef93b1b85778447fc90f59fa247ced9d64578612 Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Mon, 14 Oct 2019 16:37:09 +0530 Subject: [PATCH] Task #14 chore: resolve MR comments --- .../site/controllers/clusterusers.json.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/com_cluster/site/controllers/clusterusers.json.php b/src/components/com_cluster/site/controllers/clusterusers.json.php index 7eda3fa..2753758 100644 --- a/src/components/com_cluster/site/controllers/clusterusers.json.php +++ b/src/components/com_cluster/site/controllers/clusterusers.json.php @@ -12,7 +12,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper; -use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Response\JsonResponse; use Joomla\CMS\MVC\Controller\BaseController; use Joomla\CMS\Session\Session; @@ -34,14 +34,20 @@ class ClusterControllerClusterUsers extends BaseController */ public function getUsersByClientId() { + $app = Factory::getApplication(); + // Check for request forgeries. - Session::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + if (!Session::checkToken()) + { + echo new JsonResponse(null, Text::_('JINVALID_TOKEN'), true); + $app->close(); + } - $clusterIds = Factory::getApplication()->input->getInt('cluster_id', 0); + $clusterIds = $app->input->getInt('cluster_id', 0); $userOptions = $allUsers = array(); // Initialize array to store dropdown options - $userOptions[] = HTMLHelper::_('select.option', "", Text::_('COM_TJFIELDS_OWNERSHIP_USER')); + $userOptions[] = HTMLHelper::_('select.option', "", Text::_('COM_CLUSTER_OWNERSHIP_USER')); // Check cluster selected or not if ($clusterIds) @@ -61,7 +67,7 @@ public function getUsersByClientId() } } - echo new JResponseJson($userOptions); - jexit(); + echo new JsonResponse($userOptions); + $app->close(); } }