From fbed7ceca83638fcccc4f06303723c80c120199c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Schoenenberger?= Date: Tue, 26 Sep 2023 11:40:37 +0200 Subject: [PATCH 1/3] feat: clear circuit breaker status on install, reset --- ps_accounts.php | 24 +++++++++++++++++++ src/Adapter/Configuration.php | 12 ++++++++++ src/Api/Client/AccountsClient.php | 8 +++++++ .../PersistentCircuitBreaker.php | 3 ++- src/Api/Client/SsoClient.php | 8 +++++++ 5 files changed, 54 insertions(+), 1 deletion(-) diff --git a/ps_accounts.php b/ps_accounts.php index 4c9fe65f9..c0e901397 100644 --- a/ps_accounts.php +++ b/ps_accounts.php @@ -56,6 +56,7 @@ class Ps_accounts extends Module 'displayDashboardTop', 'actionAdminLoginControllerLoginAfter', 'actionAdminControllerInitBefore', + 'actionModuleInstallAfter', self::HOOK_DISPLAY_ACCOUNT_UPDATE_WARNING, self::HOOK_ACTION_SHOP_ACCOUNT_LINK_AFTER, self::HOOK_ACTION_SHOP_ACCOUNT_UNLINK_AFTER, @@ -157,6 +158,7 @@ public function getAdminControllers() * * @throws PrestaShopDatabaseException * @throws PrestaShopException + * @throws Exception */ public function install() { @@ -711,6 +713,11 @@ public function hookActionShopAccountUnlinkAfter($params) // Not implemented here } + public function hookActionModuleInstallAfter($module) + { + $this->resetCircuitBreaker(); + } + /** * @return string */ @@ -864,4 +871,21 @@ protected function getOauth2Session(): PrestaShop\Module\PsAccounts\Provider\OAu { return $this->getService(\PrestaShop\Module\PsAccounts\Provider\OAuth2\PrestaShopSession::class); } + + /** + * @return void + * @throws Exception + */ + private function resetCircuitBreaker(): void + { + $this->getLogger()->info(__METHOD__); + + /** @var \PrestaShop\Module\PsAccounts\Api\Client\AccountsClient $accountsClient */ + $accountsClient = $this->getService(\PrestaShop\Module\PsAccounts\Api\Client\AccountsClient::class); + $accountsClient->getCircuitBreaker()->reset(); + + /** @var \PrestaShop\Module\PsAccounts\Api\Client\SsoClient $ssoClient */ + $ssoClient = $this->getService(\PrestaShop\Module\PsAccounts\Api\Client\SsoClient::class); + $ssoClient->getCircuitBreaker()->reset(); + } } diff --git a/src/Adapter/Configuration.php b/src/Adapter/Configuration.php index e454a0408..532f664ab 100644 --- a/src/Adapter/Configuration.php +++ b/src/Adapter/Configuration.php @@ -191,6 +191,18 @@ public function setRaw($key, $values, $html = false, $idShopGroup = null, $idSho return \Configuration::updateValue($key, $values, $html, $idShopGroup, $idShop); } + /** + * @param $key + * @param $value + * @param $html + * + * @return void + */ + public function setGlobal($key, $value, $html=false) + { + \Configuration::updateGlobalValue($key, $value, $html); + } + /** * @param string $key * @param int|null $idShopGroup diff --git a/src/Api/Client/AccountsClient.php b/src/Api/Client/AccountsClient.php index a2908c07e..e365708a7 100644 --- a/src/Api/Client/AccountsClient.php +++ b/src/Api/Client/AccountsClient.php @@ -223,6 +223,14 @@ public function updateUserShop(UpdateShop $shop) }); } + /** + * @return CircuitBreaker + */ + public function getCircuitBreaker(): CircuitBreaker + { + return $this->circuitBreaker; + } + /** * @param array $additionalHeaders * diff --git a/src/Api/Client/CircuitBreaker/PersistentCircuitBreaker.php b/src/Api/Client/CircuitBreaker/PersistentCircuitBreaker.php index 8aecc41ef..582929863 100644 --- a/src/Api/Client/CircuitBreaker/PersistentCircuitBreaker.php +++ b/src/Api/Client/CircuitBreaker/PersistentCircuitBreaker.php @@ -67,7 +67,8 @@ private function get(string $key): string */ private function set(string $key, $value): void { - $this->config->setRaw($this->getKey($key), $value, false, 0, 0); + //$this->config->setRaw($this->getKey($key), $value, false, 0, 0); + $this->config->setGlobal($this->getKey($key), $value); } private function getKey(string $key): string diff --git a/src/Api/Client/SsoClient.php b/src/Api/Client/SsoClient.php index f3776cad0..28e3adbf2 100644 --- a/src/Api/Client/SsoClient.php +++ b/src/Api/Client/SsoClient.php @@ -124,4 +124,12 @@ public function refreshToken($refreshToken) ]); }); } + + /** + * @return CircuitBreaker + */ + public function getCircuitBreaker(): CircuitBreaker + { + return $this->circuitBreaker; + } } From 4c70c0c9cd69131a1fa2e85112826f6df76c97b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Schoenenberger?= Date: Tue, 3 Oct 2023 17:47:30 +0200 Subject: [PATCH 2/3] fix: switch to multi/single shop mode --- ps_accounts.php | 8 ++ src/Adapter/Configuration.php | 47 +-------- src/Adapter/ConfigurationKeys.php | 50 ++++++++++ src/Repository/ConfigurationRepository.php | 95 ++++++++++--------- .../Api/v1/ShopLinkAccount/DeleteTest.php | 20 ++-- .../Api/v1/ShopLinkAccount/StoreTest.php | 34 +++---- .../Api/v1/ShopOauth2Client/DeleteTest.php | 10 +- .../Api/v1/ShopOauth2Client/StoreTest.php | 6 +- tests/Feature/Api/v1/ShopToken/ShowTest.php | 8 +- tests/Feature/FeatureTestCase.php | 1 + .../SetShopIdTest.php | 7 +- .../IsTokenExpiredTest.php | 1 - .../UserTokenRepository/RefreshTokenTest.php | 1 - .../IsEmailValidatedTest.php | 1 - 14 files changed, 157 insertions(+), 132 deletions(-) create mode 100644 src/Adapter/ConfigurationKeys.php diff --git a/ps_accounts.php b/ps_accounts.php index c0e901397..c355458dd 100644 --- a/ps_accounts.php +++ b/ps_accounts.php @@ -713,6 +713,13 @@ public function hookActionShopAccountUnlinkAfter($params) // Not implemented here } + /** + * @param mixed $module + * + * @return void + * + * @throws Exception + */ public function hookActionModuleInstallAfter($module) { $this->resetCircuitBreaker(); @@ -874,6 +881,7 @@ protected function getOauth2Session(): PrestaShop\Module\PsAccounts\Provider\OAu /** * @return void + * * @throws Exception */ private function resetCircuitBreaker(): void diff --git a/src/Adapter/Configuration.php b/src/Adapter/Configuration.php index 532f664ab..99a376e70 100644 --- a/src/Adapter/Configuration.php +++ b/src/Adapter/Configuration.php @@ -22,43 +22,6 @@ class Configuration { - public const PSX_UUID_V4 = 'PSX_UUID_V4'; - - // PS Shop Account - public const PS_ACCOUNTS_FIREBASE_ID_TOKEN = 'PS_ACCOUNTS_FIREBASE_ID_TOKEN'; - public const PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN = 'PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN'; - public const PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN_FAILURE = 'PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN_FAILURE'; - - // PS User Account - public const PS_ACCOUNTS_FIREBASE_EMAIL = 'PS_ACCOUNTS_FIREBASE_EMAIL'; - public const PS_ACCOUNTS_FIREBASE_EMAIL_IS_VERIFIED = 'PS_ACCOUNTS_FIREBASE_EMAIL_IS_VERIFIED'; - public const PS_ACCOUNTS_USER_FIREBASE_UUID = 'PS_ACCOUNTS_USER_FIREBASE_UUID'; - public const PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN = 'PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN'; - public const PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN = 'PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN'; - public const PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN_FAILURE = 'PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN_FAILURE'; - - // PS Backend User - public const PS_ACCOUNTS_EMPLOYEE_ID = 'PS_ACCOUNTS_EMPLOYEE_ID'; - - // API keys - public const PS_ACCOUNTS_RSA_PUBLIC_KEY = 'PS_ACCOUNTS_RSA_PUBLIC_KEY'; - public const PS_ACCOUNTS_RSA_PRIVATE_KEY = 'PS_ACCOUNTS_RSA_PRIVATE_KEY'; - public const PS_ACCOUNTS_RSA_SIGN_DATA = 'PS_ACCOUNTS_RSA_SIGN_DATA'; - - // /!\ Compat with ps_checkout - public const PS_CHECKOUT_SHOP_UUID_V4 = 'PS_CHECKOUT_SHOP_UUID_V4'; - public const PS_PSX_FIREBASE_ID_TOKEN = 'PS_PSX_FIREBASE_ID_TOKEN'; - public const PS_PSX_FIREBASE_REFRESH_TOKEN = 'PS_PSX_FIREBASE_REFRESH_TOKEN'; - public const PS_PSX_FIREBASE_REFRESH_DATE = 'PS_PSX_FIREBASE_REFRESH_DATE'; - public const PS_PSX_FIREBASE_EMAIL = 'PS_PSX_FIREBASE_EMAIL'; - - // PsAccounts SSO login enabled - public const PS_ACCOUNTS_LOGIN_ENABLED = 'PS_ACCOUNTS_LOGIN_ENABLED'; - - // OAuth2 client setup - public const PS_ACCOUNTS_OAUTH2_CLIENT_ID = 'PS_ACCOUNTS_OAUTH2_CLIENT_ID'; - public const PS_ACCOUNTS_OAUTH2_CLIENT_SECRET = 'PS_ACCOUNTS_OAUTH2_CLIENT_SECRET'; - /** * @var int */ @@ -192,15 +155,15 @@ public function setRaw($key, $values, $html = false, $idShopGroup = null, $idSho } /** - * @param $key - * @param $value - * @param $html + * @param string $key + * @param string|array $values + * @param bool $html * * @return void */ - public function setGlobal($key, $value, $html=false) + public function setGlobal($key, $values, $html = false) { - \Configuration::updateGlobalValue($key, $value, $html); + \Configuration::updateGlobalValue($key, $values, $html); } /** diff --git a/src/Adapter/ConfigurationKeys.php b/src/Adapter/ConfigurationKeys.php new file mode 100644 index 000000000..c814b7103 --- /dev/null +++ b/src/Adapter/ConfigurationKeys.php @@ -0,0 +1,50 @@ +getConstants(); + } +} diff --git a/src/Repository/ConfigurationRepository.php b/src/Repository/ConfigurationRepository.php index 2d895d21a..27285c630 100644 --- a/src/Repository/ConfigurationRepository.php +++ b/src/Repository/ConfigurationRepository.php @@ -21,6 +21,7 @@ namespace PrestaShop\Module\PsAccounts\Repository; use PrestaShop\Module\PsAccounts\Adapter\Configuration; +use PrestaShop\Module\PsAccounts\Adapter\ConfigurationKeys; class ConfigurationRepository { @@ -62,7 +63,7 @@ public function setShopId($shopId) */ public function getFirebaseIdToken() { - return $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_ID_TOKEN); + return $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_ID_TOKEN); } /** @@ -70,7 +71,7 @@ public function getFirebaseIdToken() */ public function getFirebaseRefreshToken() { - return $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN); + return $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN); } /** @@ -81,14 +82,14 @@ public function getFirebaseRefreshToken() */ public function updateFirebaseIdAndRefreshTokens($idToken, $refreshToken) { - if (false === $this->configuration->get(Configuration::PS_PSX_FIREBASE_ID_TOKEN)) { + if (false === $this->configuration->get(ConfigurationKeys::PS_PSX_FIREBASE_ID_TOKEN)) { // FIXME: This to avoid mutual disconnect between ps_accounts & ps_checkout - $this->configuration->set(Configuration::PS_PSX_FIREBASE_ID_TOKEN, $idToken); - $this->configuration->set(Configuration::PS_PSX_FIREBASE_REFRESH_TOKEN, $refreshToken); - $this->configuration->set(Configuration::PS_PSX_FIREBASE_REFRESH_DATE, date('Y-m-d H:i:s')); + $this->configuration->set(ConfigurationKeys::PS_PSX_FIREBASE_ID_TOKEN, $idToken); + $this->configuration->set(ConfigurationKeys::PS_PSX_FIREBASE_REFRESH_TOKEN, $refreshToken); + $this->configuration->set(ConfigurationKeys::PS_PSX_FIREBASE_REFRESH_DATE, date('Y-m-d H:i:s')); } - $this->configuration->set(Configuration::PS_ACCOUNTS_FIREBASE_ID_TOKEN, $idToken); - $this->configuration->set(Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN, $refreshToken); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_ID_TOKEN, $idToken); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN, $refreshToken); } /** @@ -98,7 +99,7 @@ public function updateFirebaseIdAndRefreshTokens($idToken, $refreshToken) */ public function hasFirebaseRefreshToken() { - return !empty($this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN)); + return !empty($this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN)); } /** @@ -106,7 +107,7 @@ public function hasFirebaseRefreshToken() */ public function getFirebaseEmail() { - return $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_EMAIL); + return $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_EMAIL); } /** @@ -116,10 +117,10 @@ public function getFirebaseEmail() */ public function updateFirebaseEmail($email) { - if (false === $this->configuration->get(Configuration::PS_PSX_FIREBASE_EMAIL)) { - $this->configuration->set(Configuration::PS_PSX_FIREBASE_EMAIL, $email); + if (false === $this->configuration->get(ConfigurationKeys::PS_PSX_FIREBASE_EMAIL)) { + $this->configuration->set(ConfigurationKeys::PS_PSX_FIREBASE_EMAIL, $email); } - $this->configuration->set(Configuration::PS_ACCOUNTS_FIREBASE_EMAIL, $email); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_EMAIL, $email); } /** @@ -127,7 +128,7 @@ public function updateFirebaseEmail($email) */ public function getEmployeeId() { - return $this->configuration->get(Configuration::PS_ACCOUNTS_EMPLOYEE_ID); + return $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_EMPLOYEE_ID); } /** @@ -137,7 +138,7 @@ public function getEmployeeId() */ public function updateEmployeeId($employeeId) { - $this->configuration->set(Configuration::PS_ACCOUNTS_EMPLOYEE_ID, $employeeId); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_EMPLOYEE_ID, $employeeId); } /** @@ -146,7 +147,7 @@ public function updateEmployeeId($employeeId) public function firebaseEmailIsVerified() { return in_array( - $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_EMAIL_IS_VERIFIED), + $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_EMAIL_IS_VERIFIED), ['1', 1, true] ); } @@ -159,7 +160,7 @@ public function firebaseEmailIsVerified() public function updateFirebaseEmailIsVerified($status) { $this->configuration->set( - Configuration::PS_ACCOUNTS_FIREBASE_EMAIL_IS_VERIFIED, + ConfigurationKeys::PS_ACCOUNTS_FIREBASE_EMAIL_IS_VERIFIED, (string) $status ); } @@ -169,7 +170,7 @@ public function updateFirebaseEmailIsVerified($status) */ public function getShopUuid() { - return $this->configuration->get(Configuration::PSX_UUID_V4); + return $this->configuration->get(ConfigurationKeys::PSX_UUID_V4); } /** @@ -179,10 +180,10 @@ public function getShopUuid() */ public function updateShopUuid($uuid) { - if (false === $this->configuration->get(Configuration::PS_CHECKOUT_SHOP_UUID_V4)) { - $this->configuration->set(Configuration::PS_CHECKOUT_SHOP_UUID_V4, $uuid); + if (false === $this->configuration->get(ConfigurationKeys::PS_CHECKOUT_SHOP_UUID_V4)) { + $this->configuration->set(ConfigurationKeys::PS_CHECKOUT_SHOP_UUID_V4, $uuid); } - $this->configuration->set(Configuration::PSX_UUID_V4, $uuid); + $this->configuration->set(ConfigurationKeys::PSX_UUID_V4, $uuid); } /** @@ -190,7 +191,7 @@ public function updateShopUuid($uuid) */ public function getAccountsRsaPrivateKey() { - return $this->configuration->get(Configuration::PS_ACCOUNTS_RSA_PRIVATE_KEY); + return $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_RSA_PRIVATE_KEY); } /** @@ -200,7 +201,7 @@ public function getAccountsRsaPrivateKey() */ public function updateAccountsRsaPrivateKey($key) { - $this->configuration->set(Configuration::PS_ACCOUNTS_RSA_PRIVATE_KEY, $key); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_RSA_PRIVATE_KEY, $key); } /** @@ -208,7 +209,7 @@ public function updateAccountsRsaPrivateKey($key) */ public function getAccountsRsaPublicKey() { - return $this->configuration->get(Configuration::PS_ACCOUNTS_RSA_PUBLIC_KEY); + return $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_RSA_PUBLIC_KEY); } /** @@ -218,7 +219,7 @@ public function getAccountsRsaPublicKey() */ public function updateAccountsRsaPublicKey($key) { - $this->configuration->set(Configuration::PS_ACCOUNTS_RSA_PUBLIC_KEY, $key); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_RSA_PUBLIC_KEY, $key); } /** @@ -226,7 +227,7 @@ public function updateAccountsRsaPublicKey($key) */ public function getAccountsRsaSignData() { - return $this->configuration->get(Configuration::PS_ACCOUNTS_RSA_SIGN_DATA); + return $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_RSA_SIGN_DATA); } /** @@ -236,7 +237,7 @@ public function getAccountsRsaSignData() */ public function updateAccountsRsaSignData($signData) { - $this->configuration->set(Configuration::PS_ACCOUNTS_RSA_SIGN_DATA, $signData); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_RSA_SIGN_DATA, $signData); } /** @@ -253,7 +254,7 @@ public function sslEnabled() */ public function getUserFirebaseUuid() { - return $this->configuration->get(Configuration::PS_ACCOUNTS_USER_FIREBASE_UUID); + return $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_UUID); } /** @@ -263,7 +264,7 @@ public function getUserFirebaseUuid() */ public function updateUserFirebaseUuid($uuid) { - $this->configuration->set(Configuration::PS_ACCOUNTS_USER_FIREBASE_UUID, $uuid); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_UUID, $uuid); } /** @@ -271,7 +272,7 @@ public function updateUserFirebaseUuid($uuid) */ public function getUserFirebaseIdToken() { - return $this->configuration->get(Configuration::PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN); + return $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN); } /** @@ -281,7 +282,7 @@ public function getUserFirebaseIdToken() */ public function updateUserFirebaseIdToken($idToken) { - $this->configuration->set(Configuration::PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN, $idToken); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN, $idToken); } /** @@ -289,7 +290,7 @@ public function updateUserFirebaseIdToken($idToken) */ public function getUserFirebaseRefreshToken() { - return $this->configuration->get(Configuration::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN); + return $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN); } /** @@ -299,7 +300,7 @@ public function getUserFirebaseRefreshToken() */ public function updateUserFirebaseRefreshToken($refreshToken) { - $this->configuration->set(Configuration::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN, $refreshToken); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN, $refreshToken); } /** @@ -319,13 +320,15 @@ public function getMainShop() * specify id_shop & id_shop_group for shop * * @return void + * + * @throws \PrestaShopDatabaseException */ public function migrateToMultiShop() { $shop = $this->getMainShop(); \Db::getInstance()->query( 'UPDATE ' . _DB_PREFIX_ . 'configuration SET id_shop = ' . (int) $shop->id . ', id_shop_group = ' . (int) $shop->id_shop_group . - " WHERE (name like 'PS_ACCOUNTS_%' OR name = 'PSX_UUID_V4')" . + " WHERE name IN('" . join("','", array_values(ConfigurationKeys::getKeys())) . "')" . ' AND id_shop IS NULL AND id_shop_group IS NULL;' ); } @@ -334,13 +337,15 @@ public function migrateToMultiShop() * nullify id_shop & id_shop_group for shop * * @return void + * + * @throws \PrestaShopDatabaseException */ public function migrateToSingleShop() { $shop = $this->getMainShop(); \Db::getInstance()->query( 'UPDATE ' . _DB_PREFIX_ . 'configuration SET id_shop = NULL, id_shop_group = NULL' . - " WHERE (name like 'PS_ACCOUNTS_%' OR name = 'PSX_UUID_V4')" . + " WHERE name IN('" . join("','", array_values(ConfigurationKeys::getKeys())) . "')" . ' AND id_shop = ' . (int) $shop->id . ';' ); } @@ -350,7 +355,7 @@ public function migrateToSingleShop() */ public function getLoginEnabled() { - return (bool) $this->configuration->get(Configuration::PS_ACCOUNTS_LOGIN_ENABLED); + return (bool) $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_LOGIN_ENABLED); } /** @@ -360,7 +365,7 @@ public function getLoginEnabled() */ public function updateLoginEnabled($enabled) { - $this->configuration->set(Configuration::PS_ACCOUNTS_LOGIN_ENABLED, (string) $enabled); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_LOGIN_ENABLED, (string) $enabled); } /** @@ -368,7 +373,7 @@ public function updateLoginEnabled($enabled) */ public function getOauth2ClientId() { - return $this->configuration->get(Configuration::PS_ACCOUNTS_OAUTH2_CLIENT_ID); + return $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_OAUTH2_CLIENT_ID); } /** @@ -378,7 +383,7 @@ public function getOauth2ClientId() */ public function updateOauth2ClientId($clientId) { - $this->configuration->set(Configuration::PS_ACCOUNTS_OAUTH2_CLIENT_ID, $clientId); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_OAUTH2_CLIENT_ID, $clientId); } /** @@ -386,7 +391,7 @@ public function updateOauth2ClientId($clientId) */ public function getOauth2ClientSecret() { - return $this->configuration->get(Configuration::PS_ACCOUNTS_OAUTH2_CLIENT_SECRET); + return $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_OAUTH2_CLIENT_SECRET); } /** @@ -396,7 +401,7 @@ public function getOauth2ClientSecret() */ public function updateOauth2ClientSecret($secret) { - $this->configuration->set(Configuration::PS_ACCOUNTS_OAUTH2_CLIENT_SECRET, $secret); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_OAUTH2_CLIENT_SECRET, $secret); } /** @@ -407,11 +412,11 @@ public function updateOauth2ClientSecret($secret) public function getRefreshTokenFailure($type) { if ($type === 'shop') { - return (int) $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN_FAILURE, '0'); + return (int) $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN_FAILURE, '0'); } if ($type === 'user') { - return (int) $this->configuration->get(Configuration::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN_FAILURE, '0'); + return (int) $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN_FAILURE, '0'); } return 0; @@ -427,10 +432,10 @@ public function updateRefreshTokenFailure($type, $attempt) { switch ($type) { case 'shop': - $this->configuration->set(Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN_FAILURE, (string) $attempt); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN_FAILURE, (string) $attempt); break; case 'user': - $this->configuration->set(Configuration::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN_FAILURE, (string) $attempt); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN_FAILURE, (string) $attempt); break; default: break; diff --git a/tests/Feature/Api/v1/ShopLinkAccount/DeleteTest.php b/tests/Feature/Api/v1/ShopLinkAccount/DeleteTest.php index f9e152343..f2ea05f14 100644 --- a/tests/Feature/Api/v1/ShopLinkAccount/DeleteTest.php +++ b/tests/Feature/Api/v1/ShopLinkAccount/DeleteTest.php @@ -2,7 +2,7 @@ namespace PrestaShop\Module\PsAccounts\Tests\Feature\Api\v1\ShopLinkAccount; -use PrestaShop\Module\PsAccounts\Adapter\Configuration; +use PrestaShop\Module\PsAccounts\Adapter\ConfigurationKeys; use PrestaShop\Module\PsAccounts\Controller\AbstractRestController; use PrestaShop\Module\PsAccounts\Tests\Feature\FeatureTestCase; @@ -15,7 +15,7 @@ class DeleteTest extends FeatureTestCase */ public function itShouldSucceed() { - $this->configuration->set(Configuration::PS_ACCOUNTS_FIREBASE_ID_TOKEN, 'foobar'); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_ID_TOKEN, 'foobar'); $response = $this->client->delete('/module/ps_accounts/apiV1ShopLinkAccount', [ 'headers' => [ @@ -38,15 +38,15 @@ public function itShouldSucceed() \Configuration::clearConfigurationCacheForTesting(); \Configuration::loadConfiguration(); - $this->assertEmpty($this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_ID_TOKEN)); - $this->assertEmpty($this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN)); + $this->assertEmpty($this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_ID_TOKEN)); + $this->assertEmpty($this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN)); - $this->assertEmpty($this->configuration->get(Configuration::PS_ACCOUNTS_USER_FIREBASE_UUID)); - $this->assertEmpty($this->configuration->get(Configuration::PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN)); - $this->assertEmpty($this->configuration->get(Configuration::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN)); + $this->assertEmpty($this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_UUID)); + $this->assertEmpty($this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN)); + $this->assertEmpty($this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN)); - $this->assertEmpty($this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_EMAIL)); - $this->assertEmpty($this->configuration->get(Configuration::PSX_UUID_V4)); - $this->assertEmpty($this->configuration->get(Configuration::PS_ACCOUNTS_EMPLOYEE_ID)); + $this->assertEmpty($this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_EMAIL)); + $this->assertEmpty($this->configuration->get(ConfigurationKeys::PSX_UUID_V4)); + $this->assertEmpty($this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_EMPLOYEE_ID)); } } diff --git a/tests/Feature/Api/v1/ShopLinkAccount/StoreTest.php b/tests/Feature/Api/v1/ShopLinkAccount/StoreTest.php index d381398ee..74c4ce309 100644 --- a/tests/Feature/Api/v1/ShopLinkAccount/StoreTest.php +++ b/tests/Feature/Api/v1/ShopLinkAccount/StoreTest.php @@ -2,7 +2,7 @@ namespace PrestaShop\Module\PsAccounts\Tests\Feature\Api\v1\ShopLinkAccount; -use PrestaShop\Module\PsAccounts\Adapter\Configuration; +use PrestaShop\Module\PsAccounts\Adapter\ConfigurationKeys; use PrestaShop\Module\PsAccounts\Controller\AbstractRestController; use PrestaShop\Module\PsAccounts\Tests\Feature\FeatureTestCase; @@ -48,16 +48,16 @@ public function itShouldSucceed() \Configuration::clearConfigurationCacheForTesting(); \Configuration::loadConfiguration(); - $this->assertEquals($payload['shop_token'], $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_ID_TOKEN)); - $this->assertEquals($payload['shop_refresh_token'], $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN)); + $this->assertEquals($payload['shop_token'], $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_ID_TOKEN)); + $this->assertEquals($payload['shop_refresh_token'], $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN)); - $this->assertEquals($userUuid, $this->configuration->get(Configuration::PS_ACCOUNTS_USER_FIREBASE_UUID)); - $this->assertEquals($payload['user_token'], $this->configuration->get(Configuration::PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN)); - $this->assertEquals($payload['user_refresh_token'], $this->configuration->get(Configuration::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN)); + $this->assertEquals($userUuid, $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_UUID)); + $this->assertEquals($payload['user_token'], $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN)); + $this->assertEquals($payload['user_refresh_token'], $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN)); - $this->assertEquals($email, $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_EMAIL)); - $this->assertEquals($shopUuid, $this->configuration->get(Configuration::PSX_UUID_V4)); - $this->assertEquals($employeeId, $this->configuration->get(Configuration::PS_ACCOUNTS_EMPLOYEE_ID)); + $this->assertEquals($email, $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_EMAIL)); + $this->assertEquals($shopUuid, $this->configuration->get(ConfigurationKeys::PSX_UUID_V4)); + $this->assertEquals($employeeId, $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_EMPLOYEE_ID)); } /** @@ -98,15 +98,15 @@ public function itShouldSucceedWithoutEmployeeId() \Configuration::clearConfigurationCacheForTesting(); \Configuration::loadConfiguration(); - $this->assertEquals($payload['shop_token'], $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_ID_TOKEN)); - $this->assertEquals($payload['shop_refresh_token'], $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN)); + $this->assertEquals($payload['shop_token'], $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_ID_TOKEN)); + $this->assertEquals($payload['shop_refresh_token'], $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN)); - $this->assertEquals($userUuid, $this->configuration->get(Configuration::PS_ACCOUNTS_USER_FIREBASE_UUID)); - $this->assertEquals($payload['user_token'], $this->configuration->get(Configuration::PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN)); - $this->assertEquals($payload['user_refresh_token'], $this->configuration->get(Configuration::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN)); + $this->assertEquals($userUuid, $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_UUID)); + $this->assertEquals($payload['user_token'], $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN)); + $this->assertEquals($payload['user_refresh_token'], $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN)); - $this->assertEquals($email, $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_EMAIL)); - $this->assertEquals($shopUuid, $this->configuration->get(Configuration::PSX_UUID_V4)); - $this->assertEquals('', $this->configuration->get(Configuration::PS_ACCOUNTS_EMPLOYEE_ID)); + $this->assertEquals($email, $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_EMAIL)); + $this->assertEquals($shopUuid, $this->configuration->get(ConfigurationKeys::PSX_UUID_V4)); + $this->assertEquals('', $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_EMPLOYEE_ID)); } } diff --git a/tests/Feature/Api/v1/ShopOauth2Client/DeleteTest.php b/tests/Feature/Api/v1/ShopOauth2Client/DeleteTest.php index c01164772..fa912bcad 100644 --- a/tests/Feature/Api/v1/ShopOauth2Client/DeleteTest.php +++ b/tests/Feature/Api/v1/ShopOauth2Client/DeleteTest.php @@ -2,7 +2,7 @@ namespace PrestaShop\Module\PsAccounts\Tests\Feature\Api\v1\ShopOauth2Client; -use PrestaShop\Module\PsAccounts\Adapter\Configuration; +use PrestaShop\Module\PsAccounts\Adapter\ConfigurationKeys; use PrestaShop\Module\PsAccounts\Controller\AbstractRestController; use PrestaShop\Module\PsAccounts\Tests\Feature\FeatureTestCase; @@ -13,8 +13,8 @@ class DeleteTest extends FeatureTestCase */ public function itShouldSucceed() { - $this->configuration->set(Configuration::PS_ACCOUNTS_OAUTH2_CLIENT_ID, $this->faker->slug); - $this->configuration->set(Configuration::PS_ACCOUNTS_OAUTH2_CLIENT_SECRET, $this->faker->password); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_OAUTH2_CLIENT_ID, $this->faker->slug); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_OAUTH2_CLIENT_SECRET, $this->faker->password); $response = $this->client->delete('/module/ps_accounts/apiV1ShopOauth2Client', [ 'headers' => [ @@ -37,7 +37,7 @@ public function itShouldSucceed() \Configuration::clearConfigurationCacheForTesting(); \Configuration::loadConfiguration(); - $this->assertEmpty($this->configuration->get(Configuration::PS_ACCOUNTS_OAUTH2_CLIENT_ID)); - $this->assertEmpty($this->configuration->get(Configuration::PS_ACCOUNTS_OAUTH2_CLIENT_SECRET)); + $this->assertEmpty($this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_OAUTH2_CLIENT_ID)); + $this->assertEmpty($this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_OAUTH2_CLIENT_SECRET)); } } diff --git a/tests/Feature/Api/v1/ShopOauth2Client/StoreTest.php b/tests/Feature/Api/v1/ShopOauth2Client/StoreTest.php index 3cd504158..e65ecf96f 100644 --- a/tests/Feature/Api/v1/ShopOauth2Client/StoreTest.php +++ b/tests/Feature/Api/v1/ShopOauth2Client/StoreTest.php @@ -2,7 +2,7 @@ namespace PrestaShop\Module\PsAccounts\Tests\Feature\Api\v1\ShopOauth2Client; -use PrestaShop\Module\PsAccounts\Adapter\Configuration; +use PrestaShop\Module\PsAccounts\Adapter\ConfigurationKeys; use PrestaShop\Module\PsAccounts\Controller\AbstractRestController; use PrestaShop\Module\PsAccounts\Tests\Feature\FeatureTestCase; @@ -37,8 +37,8 @@ public function itShouldSucceed() \Configuration::clearConfigurationCacheForTesting(); \Configuration::loadConfiguration(); - $this->assertEquals($payload['client_id'], $this->configuration->get(Configuration::PS_ACCOUNTS_OAUTH2_CLIENT_ID)); - $this->assertEquals($payload['client_secret'], $this->configuration->get(Configuration::PS_ACCOUNTS_OAUTH2_CLIENT_SECRET)); + $this->assertEquals($payload['client_id'], $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_OAUTH2_CLIENT_ID)); + $this->assertEquals($payload['client_secret'], $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_OAUTH2_CLIENT_SECRET)); } /** diff --git a/tests/Feature/Api/v1/ShopToken/ShowTest.php b/tests/Feature/Api/v1/ShopToken/ShowTest.php index c4a800caf..b944150af 100644 --- a/tests/Feature/Api/v1/ShopToken/ShowTest.php +++ b/tests/Feature/Api/v1/ShopToken/ShowTest.php @@ -2,7 +2,7 @@ namespace PrestaShop\Module\PsAccounts\Tests\Feature\Api\v1\ShopToken; -use PrestaShop\Module\PsAccounts\Adapter\Configuration; +use PrestaShop\Module\PsAccounts\Adapter\ConfigurationKeys; use PrestaShop\Module\PsAccounts\Controller\AbstractRestController; use PrestaShop\Module\PsAccounts\Tests\Feature\FeatureTestCase; @@ -30,11 +30,11 @@ public function itShouldSucceed() $this->assertResponseOk($response); $this->assertArraySubset([ - 'token' => $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_ID_TOKEN), - 'refresh_token' => $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN), + 'token' => $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_ID_TOKEN), + 'refresh_token' => $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN), ], $json); - $this->assertEquals(0, $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN_FAILURE)); + $this->assertEquals(0, $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN_FAILURE)); } /** diff --git a/tests/Feature/FeatureTestCase.php b/tests/Feature/FeatureTestCase.php index 30731b44c..91eb9d106 100644 --- a/tests/Feature/FeatureTestCase.php +++ b/tests/Feature/FeatureTestCase.php @@ -14,6 +14,7 @@ use PrestaShop\Module\PsAccounts\Repository\UserTokenRepository; use PrestaShop\Module\PsAccounts\Tests\TestCase; + class FeatureTestCase extends TestCase { /** diff --git a/tests/Unit/Repository/ConfigurationRespository/SetShopIdTest.php b/tests/Unit/Repository/ConfigurationRespository/SetShopIdTest.php index e697681e6..1db28ddf7 100644 --- a/tests/Unit/Repository/ConfigurationRespository/SetShopIdTest.php +++ b/tests/Unit/Repository/ConfigurationRespository/SetShopIdTest.php @@ -3,6 +3,7 @@ namespace PrestaShop\Module\PsAccounts\Tests\Unit\Repository\ConfigurationRespository; use PrestaShop\Module\PsAccounts\Adapter\Configuration; +use PrestaShop\Module\PsAccounts\Adapter\ConfigurationKeys; use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository; use PrestaShop\Module\PsAccounts\Tests\TestCase; @@ -22,7 +23,7 @@ public function itShouldPassShopIdCallingGet() $configMock->expects($this->once()) ->method('getRaw') - ->with(Configuration::PS_ACCOUNTS_FIREBASE_EMAIL, null, null, $shopId, false); + ->with(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_EMAIL, null, null, $shopId, false); $configuration = new ConfigurationRepository($configMock); $configuration->setShopId($shopId); @@ -45,10 +46,10 @@ public function itShouldPassShopIdCallingUpdate() $configMock->expects($this->once()) ->method('get') - ->with(Configuration::PS_PSX_FIREBASE_EMAIL); + ->with(ConfigurationKeys::PS_PSX_FIREBASE_EMAIL); $configMock->expects($this->once()) ->method('setRaw') - ->with(Configuration::PS_ACCOUNTS_FIREBASE_EMAIL, $email, false, null, $shopId); + ->with(ConfigurationKeys::PS_ACCOUNTS_FIREBASE_EMAIL, $email, false, null, $shopId); $configuration = new ConfigurationRepository($configMock); $configuration->setShopId($shopId); diff --git a/tests/Unit/Repository/UserTokenRepository/IsTokenExpiredTest.php b/tests/Unit/Repository/UserTokenRepository/IsTokenExpiredTest.php index 4ab2cb080..220be2bd1 100644 --- a/tests/Unit/Repository/UserTokenRepository/IsTokenExpiredTest.php +++ b/tests/Unit/Repository/UserTokenRepository/IsTokenExpiredTest.php @@ -3,7 +3,6 @@ namespace PrestaShop\Module\PsAccounts\Tests\Unit\Repository\UserTokenRepository; use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository; -use PrestaShop\Module\PsAccounts\Repository\ShopTokenRepository; use PrestaShop\Module\PsAccounts\Repository\UserTokenRepository; use PrestaShop\Module\PsAccounts\Tests\TestCase; diff --git a/tests/Unit/Repository/UserTokenRepository/RefreshTokenTest.php b/tests/Unit/Repository/UserTokenRepository/RefreshTokenTest.php index 899412adf..c03627335 100644 --- a/tests/Unit/Repository/UserTokenRepository/RefreshTokenTest.php +++ b/tests/Unit/Repository/UserTokenRepository/RefreshTokenTest.php @@ -22,7 +22,6 @@ use Exception; use Lcobucci\JWT\Token; -use PrestaShop\Module\PsAccounts\Api\Client\AccountsClient; use PrestaShop\Module\PsAccounts\Api\Client\SsoClient; use PrestaShop\Module\PsAccounts\Exception\RefreshTokenException; use PrestaShop\Module\PsAccounts\Repository\AbstractTokenRepository; diff --git a/tests/Unit/Service/PsAccountsService/IsEmailValidatedTest.php b/tests/Unit/Service/PsAccountsService/IsEmailValidatedTest.php index 520b70be7..97fe8bec3 100644 --- a/tests/Unit/Service/PsAccountsService/IsEmailValidatedTest.php +++ b/tests/Unit/Service/PsAccountsService/IsEmailValidatedTest.php @@ -2,7 +2,6 @@ namespace PrestaShop\Module\PsAccounts\Tests\Unit\Service\PsAccountsService; -use PrestaShop\Module\PsAccounts\Repository\ShopTokenRepository; use PrestaShop\Module\PsAccounts\Repository\UserTokenRepository; use PrestaShop\Module\PsAccounts\Service\PsAccountsService; use PrestaShop\Module\PsAccounts\Tests\TestCase; From 1dbc5f2c8317f4dff7601398f6e14241836e8d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Schoenenberger?= Date: Tue, 3 Oct 2023 17:56:32 +0200 Subject: [PATCH 3/3] feat: new key --- src/Adapter/ConfigurationKeys.php | 1 + src/Repository/ConfigurationRepository.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Adapter/ConfigurationKeys.php b/src/Adapter/ConfigurationKeys.php index c814b7103..82d3eee76 100644 --- a/src/Adapter/ConfigurationKeys.php +++ b/src/Adapter/ConfigurationKeys.php @@ -20,6 +20,7 @@ class ConfigurationKeys public const PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN = 'PS_ACCOUNTS_USER_FIREBASE_ID_TOKEN'; public const PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN = 'PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN'; public const PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN_FAILURE = 'PS_ACCOUNTS_USER_FIREBASE_REFRESH_TOKEN_FAILURE'; + public const PS_ACCOUNTS_SHOP_UNLINKED_AUTO = 'PS_ACCOUNTS_SHOP_UNLINKED_AUTO'; // PS Backend User public const PS_ACCOUNTS_EMPLOYEE_ID = 'PS_ACCOUNTS_EMPLOYEE_ID'; diff --git a/src/Repository/ConfigurationRepository.php b/src/Repository/ConfigurationRepository.php index d1304a906..1f9c0f1a0 100644 --- a/src/Repository/ConfigurationRepository.php +++ b/src/Repository/ConfigurationRepository.php @@ -447,7 +447,7 @@ public function updateRefreshTokenFailure($type, $attempt) */ public function getShopUnlinkedAuto() { - return (bool) $this->configuration->get(Configuration::PS_ACCOUNTS_SHOP_UNLINKED_AUTO, '0'); + return (bool) $this->configuration->get(ConfigurationKeys::PS_ACCOUNTS_SHOP_UNLINKED_AUTO, '0'); } /** @@ -457,6 +457,6 @@ public function getShopUnlinkedAuto() */ public function updateShopUnlinkedAuto($status) { - $this->configuration->set(Configuration::PS_ACCOUNTS_SHOP_UNLINKED_AUTO, (string) $status); + $this->configuration->set(ConfigurationKeys::PS_ACCOUNTS_SHOP_UNLINKED_AUTO, (string) $status); } }