Skip to content

Commit c6495ab

Browse files
committed
OXDEV-9078 Move user settings service to Settings namespace
Signed-off-by: Anton Fedurtsya <anton@fedurtsya.com>
1 parent ceecd64 commit c6495ab

14 files changed

Lines changed: 55 additions & 58 deletions

File tree

metadata.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Metadata version
1010
*/
1111

12-
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFASettings as TwoFactorAuthModuleSettings;
12+
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFAShopSettings as TwoFactorAuthModuleSettings;
1313
use OxidEsales\SecurityModule\PasswordPolicy\Service\ModuleSettingsService as PasswordPolicyModuleSettings;
1414
use OxidEsales\SecurityModule\Captcha\Service\ModuleSettingsService as CaptchaModuleSettings;
1515
use OxidEsales\SecurityModule\Authentication\OAuth2\Service\ModuleSettingsService as OAuthModuleSettings;
@@ -171,6 +171,7 @@
171171
'value' => false
172172
],
173173
[
174+
//todo-high: should be moved to the user settings (near by 2FA turning on switch)
174175
'group' => 'two_factor_auth',
175176
'name' => TwoFactorAuthModuleSettings::TWO_FACTOR_TYPE,
176177
'type' => 'select',

src/Authentication/TwoFactorAuth/Controller/AccountSecurityController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use OxidEsales\Eshop\Application\Controller\FrontendController;
1313
use OxidEsales\Eshop\Core\Registry;
14-
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Service\TwoFAUserSettingsServiceInterface;
14+
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFAUserSettingsInterface;
1515

1616
class AccountSecurityController extends FrontendController
1717
{
@@ -22,7 +22,7 @@ class AccountSecurityController extends FrontendController
2222
protected $_sThisTemplate = '@oe_security_module/templates/account_security';
2323

2424
public function __construct(
25-
private readonly TwoFAUserSettingsServiceInterface $userSettingsService,
25+
private readonly TwoFAUserSettingsInterface $userSettingsService,
2626
) {
2727
parent::__construct();
2828
}

src/Authentication/TwoFactorAuth/Factory/TwoFAServiceFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Exception\AuthenticationTypeNotFoundException;
1313
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Service\TwoFAServiceInterface;
14-
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFASettingsInterface;
14+
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFAShopSettingsInterface;
1515

1616
class TwoFAServiceFactory implements TwoFAServiceFactoryInterface
1717
{
1818
public function __construct(
19-
private TwoFASettingsInterface $settings,
19+
private TwoFAShopSettingsInterface $settings,
2020
private array $implementations,
2121
) {
2222
}

src/Authentication/TwoFactorAuth/Service/TwoFAUserService.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
use OxidEsales\Eshop\Core\Utils;
1313
use OxidEsales\EshopCommunity\Internal\Framework\Session\SessionInterface;
1414
use OxidEsales\SecurityModule\Authentication\Service\InternalRedirectServiceInterface;
15-
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Infrastructure\Repository\UserRepositoryInterface;
1615
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Infrastructure\Service\UserLoginAdapterInterface;
17-
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFASettingsInterface;
16+
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFAShopSettingsInterface;
17+
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFAUserSettingsInterface;
1818

1919
/**
2020
* todo-high: challenge the idea - session part should go to the separate login state service
@@ -25,12 +25,12 @@ class TwoFAUserService implements TwoFAUserServiceInterface
2525

2626
public function __construct(
2727
private TwoFAServiceInterface $twoFAService,
28-
private TwoFASettingsInterface $settings,
28+
private TwoFAShopSettingsInterface $settings,
2929
private Utils $utils,
3030
private SessionInterface $session,
3131
private UserLoginAdapterInterface $loginAdapter,
3232
private InternalRedirectServiceInterface $redirectService,
33-
private UserRepositoryInterface $userRepository,
33+
private TwoFAUserSettingsInterface $userSettings,
3434
) {
3535
}
3636

@@ -67,7 +67,6 @@ public function isTwoFARequired(string $userId): bool
6767
return false;
6868
}
6969

70-
$user = $this->userRepository->getUserById($userId);
71-
return $user->isTwoFAEnabled();
70+
return $this->userSettings->isEnabledForUser($userId);
7271
}
7372
}

src/Authentication/TwoFactorAuth/Service/services.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,3 @@ services:
99
class: OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Service\TwoFAUserService
1010
public: true
1111

12-
OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Service\TwoFAUserSettingsServiceInterface:
13-
class: OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Service\TwoFAUserSettingsService
14-
public: true

src/Authentication/TwoFactorAuth/Settings/TwoFASettings.php renamed to src/Authentication/TwoFactorAuth/Settings/TwoFAShopSettings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
1414
use OxidEsales\SecurityModule\Core\Module;
1515

16-
class TwoFASettings implements TwoFASettingsInterface
16+
class TwoFAShopSettings implements TwoFAShopSettingsInterface
1717
{
1818
public const ACTIVE = 'oeSecurityTwoFactorAuthEnabled';
1919

src/Authentication/TwoFactorAuth/Settings/TwoFASettingsInterface.php renamed to src/Authentication/TwoFactorAuth/Settings/TwoFAShopSettingsInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings;
1111

12-
interface TwoFASettingsInterface
12+
interface TwoFAShopSettingsInterface
1313
{
1414
public function isTwoFactorAuthEnabled(): bool;
1515

src/Authentication/TwoFactorAuth/Service/TwoFAUserSettingsService.php renamed to src/Authentication/TwoFactorAuth/Settings/TwoFAUserSettings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
declare(strict_types=1);
99

10-
namespace OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Service;
10+
namespace OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings;
1111

1212
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Infrastructure\Repository\UserRepositoryInterface;
1313

14-
class TwoFAUserSettingsService implements TwoFAUserSettingsServiceInterface
14+
class TwoFAUserSettings implements TwoFAUserSettingsInterface
1515
{
1616
public function __construct(
1717
private UserRepositoryInterface $userRepository,

src/Authentication/TwoFactorAuth/Service/TwoFAUserSettingsServiceInterface.php renamed to src/Authentication/TwoFactorAuth/Settings/TwoFAUserSettingsInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
declare(strict_types=1);
99

10-
namespace OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Service;
10+
namespace OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings;
1111

1212
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Exception\UserNotFoundException;
1313

14-
interface TwoFAUserSettingsServiceInterface
14+
interface TwoFAUserSettingsInterface
1515
{
1616
/** @throws UserNotFoundException */
1717
public function isEnabledForUser(string $userId): bool;

src/Authentication/TwoFactorAuth/Settings/services.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ services:
33
autowire: true
44
public: false
55

6-
OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFASettingsInterface:
7-
class: OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFASettings
6+
OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFAShopSettingsInterface:
7+
class: OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFAShopSettings
8+
public: true
9+
10+
OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFAUserSettingsInterface:
11+
class: OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Settings\TwoFAUserSettings
812
public: true

0 commit comments

Comments
 (0)