Skip to content

Commit

Permalink
remove recaptcha from the route
Browse files Browse the repository at this point in the history
  • Loading branch information
stentrop committed Mar 19, 2024
1 parent 900661c commit 5a99c15
Showing 1 changed file with 18 additions and 33 deletions.
51 changes: 18 additions & 33 deletions src/Api/Resources/CustomerResource.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
<?php //strict
<?php

namespace IO\Api\Resources;

use IO\Constants\LogLevel;
use IO\Helper\ReCaptcha;
use IO\Services\NotificationService;
use IO\Api\ApiResponse;
use IO\Api\ResponseCode;
use IO\Services\CustomerService;
use Plenty\Modules\Account\Contact\Models\Contact;
use Plenty\Modules\Webshop\Contracts\ContactRepositoryContract;
use Plenty\Modules\Webshop\Events\ValidateVatNumber;
use Plenty\Plugin\Events\Dispatcher;
use Plenty\Plugin\Http\Response;
use Plenty\Plugin\Http\Request;
use IO\Api\ApiResource;
use IO\Api\ApiResponse;
use IO\Api\ResponseCode;
use IO\Services\CustomerService;
use Plenty\Plugin\Http\Response;

/**
* Class CustomerResource
Expand All @@ -31,9 +26,9 @@ class CustomerResource extends SessionResource

/**
* CustomerResource constructor.
* @param Request $request
* @param ApiResponse $response
* @param CustomerService $customerService
* @param Request $request
* @param ApiResponse $response
* @param CustomerService $customerService
*/
public function __construct(
Request $request,
Expand All @@ -44,15 +39,6 @@ public function __construct(
$this->customerService = $customerService;
}

/**
* Get the contact.
* @return Response
*/
public function index(): Response
{
return $this->response->create($this->indexCustomer(), ResponseCode::OK);
}

/**
* Save the contact.
* @return Response
Expand All @@ -66,16 +52,6 @@ public function store(): Response
return $this->response->create(true, ResponseCode::OK);
}

if (!ReCaptcha::verify($this->request->get('recaptcha', null))) {
/**
* @var NotificationService $notificationService
*/
$notificationService = pluginApp(NotificationService::class);
$notificationService->addNotificationCode(LogLevel::ERROR, 13);

return $this->response->create('', ResponseCode::BAD_REQUEST);
}

$contactData = $this->request->get('contact', null);
$billingAddressData = $this->request->get('billingAddress', []);
$deliveryAddressData = $this->request->get('deliveryAddress', []);
Expand All @@ -90,7 +66,7 @@ public function store(): Response
return $this->response->create(null, ResponseCode::BAD_REQUEST);
}

/** @var Dispatcher $eventDispatcher */
/** @var Dispatcher $eventDispatcher */
$eventDispatcher = pluginApp(Dispatcher::class);

if (count($billingAddressData) === 0) {
Expand Down Expand Up @@ -123,4 +99,13 @@ public function store(): Response

return $this->index();
}

/**
* Get the contact.
* @return Response
*/
public function index(): Response
{
return $this->response->create($this->indexCustomer(), ResponseCode::OK);
}
}

0 comments on commit 5a99c15

Please sign in to comment.