Skip to content

Commit 00aaa80

Browse files
committed
ACP2E-3501: VAPT: Business Logic Error - future date as customer date of birth
1 parent 443453f commit 00aaa80

File tree

1 file changed

+4
-6
lines changed
  • app/code/Magento/Customer/Model/Validator

1 file changed

+4
-6
lines changed

app/code/Magento/Customer/Model/Validator/Dob.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Customer\Model\Customer;
1111
use Magento\Framework\Validator\AbstractValidator;
12+
use Magento\Store\Api\Data\StoreInterface as StoreInterface;
1213
use Magento\Store\Model\StoreManagerInterface;
1314

1415
/**
@@ -41,7 +42,7 @@ public function __construct(StoreManagerInterface $storeManager)
4142
* @param Customer $customer
4243
* @return bool
4344
*/
44-
public function isValid($customer)
45+
public function isValid($customer): bool
4546
{
4647
if (!$this->isValidDob($customer->getDob(), $customer->getStoreId())) {
4748
parent::_addMessages([['dob' => 'The Date of Birth should not be greater than today.']]);
@@ -54,13 +55,11 @@ public function isValid($customer)
5455
* Check if specified dob is not in the future
5556
*
5657
* @param string|null $dobValue
57-
* @param int $storeId
58+
* @param null|string|bool|int|StoreInterface $storeId
5859
* @return bool
5960
*/
60-
private function isValidDob(?string $dobValue, int $storeId): bool
61+
private function isValidDob(?string $dobValue, null|string|bool|int|StoreInterface $storeId): bool
6162
{
62-
if ($dobValue != null) {
63-
6463
// Get the timezone of the store
6564
$store = $this->storeManager->getStore($storeId);
6665
$timezone = $store->getConfig('general/locale/timezone');
@@ -77,7 +76,6 @@ private function isValidDob(?string $dobValue, int $storeId): bool
7776
if ($dobTimestamp > $currentTimestamp) {
7877
return false;
7978
}
80-
}
8179

8280
return true;
8381
}

0 commit comments

Comments
 (0)