Change retrieval of API username. #579

This commit is contained in:
Korina Cordero 2021-06-10 08:07:27 +00:00
parent 3937b73454
commit 009d3d3267
2 changed files with 2 additions and 31 deletions

View file

@ -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_<insert name of api user here>
$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;
}
}

View file

@ -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_<insert name of api user here>
$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;
}
}