Fix customer record association when submitting a delete request #746
This commit is contained in:
parent
9ad1f0d9b2
commit
18c295f2b1
2 changed files with 14 additions and 4 deletions
|
|
@ -248,16 +248,16 @@ apiv2_rider_review_tags:
|
|||
|
||||
# account deletion
|
||||
apiv2_account_delete:
|
||||
path: /apiv2/account
|
||||
path: /apiv2/account_delete
|
||||
controller: App\Controller\CustomerAppAPI\AccountController::deleteAccount
|
||||
methods: [DELETE]
|
||||
methods: [POST]
|
||||
|
||||
apiv2_account_delete_resend_code:
|
||||
path: /apiv2/account_resend_code
|
||||
path: /apiv2/account_delete_resend_code
|
||||
controller: App\Controller\CustomerAppAPI\AccountController:resendCode
|
||||
methods: [POST]
|
||||
|
||||
apiv2_account_delete_code_validate:
|
||||
path: /apiv2/account_code_validate
|
||||
path: /apiv2/account_delete_code_validate
|
||||
controller: App\Controller\CustomerAppAPI\AccountController::validateDeleteCode
|
||||
methods: [POST]
|
||||
|
|
@ -6,6 +6,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Catalyst\ApiBundle\Component\Response as ApiResponse;
|
||||
use App\Entity\CustomerDeleteRequest;
|
||||
use App\Entity\Customer;
|
||||
use App\Service\RisingTideGateway;
|
||||
use DateTime;
|
||||
|
||||
|
|
@ -81,9 +82,18 @@ class AccountController extends ApiController
|
|||
return new ApiResponse(false, 'Invalid request details provided.');
|
||||
}
|
||||
|
||||
// check if a customer record exists for this phone number
|
||||
$cust_obj = $this->em->getRepository(Customer::class)->findOneBy([
|
||||
'phone_mobile' => $obj->getPhoneNumber(),
|
||||
]);
|
||||
if (empty($cust_obj)) {
|
||||
return new ApiResponse(false, 'No account exists for this phone number.');
|
||||
}
|
||||
|
||||
// confirm the request
|
||||
$obj->setConfirmed(true);
|
||||
$obj->setDateConfirmed(new DateTime());
|
||||
$obj->setCustomer($cust_obj);
|
||||
$this->em->flush();
|
||||
|
||||
// response
|
||||
|
|
|
|||
Loading…
Reference in a new issue