Skip to content

Commit 0c6befa

Browse files
OXDEV-9216 Fix password constraints usage
1 parent 8df89b9 commit 0c6befa

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Honeypot Captcha to detect and block bots without disrupting user experience.
1313
- Support of PHP 8.4
1414

15+
### Fixed
16+
- Password validators are no longer used when password policy is disabled
17+
1518
## [1.0.0] - 2024-11-27
1619
This is the stable release of v1.0.0. No changes have been made since v1.0.0-rc.1.
1720

src/Shared/Core/InputValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function checkPassword($user, $newPassword, $confirmationPassword, $shoul
2929
{
3030
$settingsService = $this->getService(ModuleSettingsServiceInterface::class);
3131
if (!$settingsService->isPasswordPolicyEnabled()) {
32-
parent::checkPassword($user, $newPassword, $confirmationPassword, $shouldCheckPasswordLength);
32+
return parent::checkPassword($user, $newPassword, $confirmationPassword, $shouldCheckPasswordLength);
3333
}
3434

3535
$passwordValidator = $this->getService(PasswordValidatorChainInterface::class);

tests/Integration/Shared/Core/InputValidatorTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OxidEsales\Eshop\Core\Exception\UserException;
1515
use OxidEsales\Eshop\Core\Registry;
1616
use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase;
17+
use OxidEsales\SecurityModule\PasswordPolicy\Service\ModuleSettingsServiceInterface as PasswordSettingsServiceInterface;
1718
use OxidEsales\SecurityModule\Shared\Core\InputValidator;
1819
use PHPUnit\Framework\Attributes\DataProvider;
1920

@@ -22,6 +23,8 @@ class InputValidatorTest extends IntegrationTestCase
2223
#[DataProvider('dataProviderPasswordError')]
2324
public function testInputValidationError($password, $expectedException): void
2425
{
26+
$this->get(PasswordSettingsServiceInterface::class)->saveIsPasswordPolicyEnabled(true);
27+
2528
$userModelMock = $this->createMock(User::class);
2629

2730
$validator = oxNew(InputValidator::class);
@@ -86,4 +89,18 @@ public function testShopPasswordCheck(): void
8689
$exception->getMessage()
8790
);
8891
}
92+
93+
public function testInputValidatorPasswordConstrainsAreSkipped(): void
94+
{
95+
$this->get(PasswordSettingsServiceInterface::class)->saveIsPasswordPolicyEnabled(false);
96+
97+
$userModelMock = $this->createMock(User::class);
98+
99+
$password = '12345678';
100+
101+
$validator = oxNew(InputValidator::class);
102+
$result = $validator->checkPassword($userModelMock, $password, $password);
103+
104+
$this->assertNull($result);
105+
}
89106
}

0 commit comments

Comments
 (0)