Skip to content

Commit

Permalink
Merge pull request #1194 from plentymarkets/feat/throttle_register_route
Browse files Browse the repository at this point in the history
add throttle to register route
  • Loading branch information
stentrop authored Mar 22, 2024
2 parents 6d06dac + b070694 commit 3c4535c
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 108 deletions.
6 changes: 5 additions & 1 deletion meta/documents/changelog_de.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

### Behoben

- Ein Fehler bei der Prüfung von kanonischen Urls in Kombination mit ausgeschlossenen ShopBooster Parametern, kann zu fehlenden alternate links führen. Dies wurde behoben.
- Ein Fehler bei der Prüfung von kanonischen URLs in Kombination mit ausgeschlossenen ShopBooster-Parametern, kann zu fehlenden alternate links führen. Dies wurde behoben.
- Es wurde ein Fehler behoben, der dazu führte, dass der Benutzer auf die Homepage umgeleitet wurde, wenn die Sprache auf der Bestellbestätigungsseite geändert wurde.
- Die Reihenfolge der Artikel auf der Wunschliste wird jetzt beibehalten.

### Geändert

- Die Route zur Kundenregistrierung `/register` enthält jetzt eine IP-basierte Limitierung im plentysystems Kern.

## v5.0.61 (2023-10-30) <a href="https://github.com/plentymarkets/plugin-io/compare/5.0.60...5.0.61" target="_blank" rel="noopener"><b>Übersicht aller Änderungen</b></a>

### Behoben
Expand Down
6 changes: 5 additions & 1 deletion meta/documents/changelog_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

### Fixed

- An error when checking canonical urls in combination with excluded ShopBooster parameters can lead to missing alternate links. This was fixed.
- An error when checking canonical URLs in combination with excluded ShopBooster parameters could lead to missing alternate links. This has been fixed.
- Solved a bug that manifested by redirecting the user to the homepage when the language was changed on order confirmation page.
- The wish list now preserves the order of the items on the list.

### Changed

- The customer registration route `/register` now contains an IP-based limitation in the plentysystems core.

## v5.0.61 (2023-10-30) <a href="https://github.com/plentymarkets/plugin-io/compare/5.0.60...5.0.61" target="_blank" rel="noopener"><b>Overview of all changes</b></a>

### Fixed
Expand Down
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);
}
}
Loading

0 comments on commit 3c4535c

Please sign in to comment.