From 009d3d326706785429c503b899cc09119ac7e3d9 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 10 Jun 2021 08:07:27 +0000 Subject: [PATCH] Change retrieval of API username. #579 --- .../CAPI/CustomerWarrantyController.php | 16 +--------------- src/Controller/CAPI/WarrantyController.php | 17 +---------------- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/src/Controller/CAPI/CustomerWarrantyController.php b/src/Controller/CAPI/CustomerWarrantyController.php index 3a7c699a..6e183cc0 100644 --- a/src/Controller/CAPI/CustomerWarrantyController.php +++ b/src/Controller/CAPI/CustomerWarrantyController.php @@ -2,8 +2,6 @@ namespace App\Controller\CAPI; -use Catalyst\APIBundle\Entity\User as APIUser; - use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\KernelInterface; @@ -320,7 +318,7 @@ class CustomerWarrantyController extends APIController // get the api_user that made the call so that it gets added to the source // source becomes CAPI_USER_ - $username = $this->getAPIUsername($em, $user_id); + $username = $this->getUser()->getName(); $source = 'CAPI_USER_' . $username; error_log('SOURCE: ' . $source); @@ -587,16 +585,4 @@ class CustomerWarrantyController extends APIController $rt->sendSMS($clean_num, 'MOTOLITE', $message); } - - protected function getAPIUsername($em, $user_id) - { - $api_user_result = $em->getRepository(APIUser::class)->findBy(['api_key' => $user_id]); - $username = ''; - foreach ($api_user_result as $api_user) - { - $username = $api_user->getName(); - } - - return $username; - } } diff --git a/src/Controller/CAPI/WarrantyController.php b/src/Controller/CAPI/WarrantyController.php index 2dc0d837..c0cd8aa8 100644 --- a/src/Controller/CAPI/WarrantyController.php +++ b/src/Controller/CAPI/WarrantyController.php @@ -2,8 +2,6 @@ namespace App\Controller\CAPI; -use Catalyst\APIBundle\Entity\User as APIUser; - use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Doctrine\ORM\Query; @@ -196,7 +194,7 @@ class WarrantyController extends APIController // get the api_user that made the call so that it gets added to the source // source becomes CAPI_USER_ - $username = $this->getAPIUsername($em, $user_id); + $username = $this->getUser()->getName(); $source = 'CAPI_USER_' . $username; @@ -788,17 +786,4 @@ class WarrantyController extends APIController $customers = $em->getRepository(Customer::class)->findBy(['phone_mobile' => $number]); return $customers; } - - protected function getAPIUsername($em, $user_id) - { - $api_user_result = $em->getRepository(APIUser::class)->findBy(['api_key' => $user_id]); - $username = ''; - foreach ($api_user_result as $api_user) - { - $username = $api_user->getName(); - } - - return $username; - } - }