From 68b9f53c14c6df489a9edae37c9f2ddd2c92bc3c Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 13 Dec 2022 22:24:33 +0100 Subject: [PATCH] improve code --- .gitignore | 1 + .php-cs-fixer.php | 13 ++++ composer.json | 1 + .../Controller/Admin/d3user_webauthn.php | 10 +-- .../Controller/Admin/d3webauthnadminlogin.php | 5 +- .../Controller/Traits/accountTrait.php | 2 +- .../Traits/checkoutGetUserTrait.php | 2 +- .../Controller/d3_account_webauthn.php | 6 +- .../Controller/d3webauthnlogin.php | 2 +- .../Model/Credential/PublicKeyCredential.php | 10 +-- .../Credential/PublicKeyCredentialList.php | 2 +- .../Exceptions/WebauthnCreateException.php | 2 +- .../Model/Exceptions/WebauthnException.php | 8 +-- .../Model/Exceptions/WebauthnGetException.php | 2 +- .../WebauthnLoginErrorException.php | 2 +- src/Application/Model/RelyingPartyEntity.php | 6 +- src/Application/Model/UserEntity.php | 6 +- src/Application/Model/Webauthn.php | 10 +-- src/Application/Model/WebauthnAfterLogin.php | 2 +- src/Application/Model/WebauthnConf.php | 2 +- src/Application/Model/WebauthnErrors.php | 6 +- src/Application/Model/WebauthnLogin.php | 2 +- .../translations/de/d3webauthn_lang.php | 6 +- .../views/admin/de/d3webauthn_lang.php | 2 +- .../views/admin/en/d3webauthn_lang.php | 2 +- src/IntelliSenseHelper.php | 66 ++++++++++++++----- .../Component/d3_webauthn_UserComponent.php | 20 +++--- .../Admin/d3_LoginController_Webauthn.php | 18 ++--- .../d3_AccountController_Webauthn.php | 2 +- ...d3_AccountDownloadsController_Webauthn.php | 2 +- ...3_AccountNewsletterController_Webauthn.php | 2 +- ...3_AccountNoticeListController_Webauthn.php | 2 +- .../d3_AccountOrderController_Webauthn.php | 2 +- .../d3_AccountPasswordController_Webauthn.php | 2 +- ...3_AccountRecommlistController_Webauthn.php | 2 +- .../d3_AccountReviewController_Webauthn.php | 2 +- .../d3_AccountUserController_Webauthn.php | 2 +- .../d3_AccountWishlistController_Webauthn.php | 2 +- .../d3_webauthn_OrderController.php | 2 +- .../d3_webauthn_PaymentController.php | 2 +- .../Controller/d3_webauthn_UserController.php | 2 +- .../Application/Model/d3_User_Webauthn.php | 4 +- src/Setup/Actions.php | 10 +-- src/Setup/Events.php | 2 +- src/metadata.php | 14 ++-- .../integration/passwordAdminAuthTest.php | 10 +-- .../integration/passwordFrontendAuthTest.php | 8 +-- .../integration/webauthnAdminAuthTest.php | 16 ++--- .../Controller/Admin/d3user_webauthnTest.php | 10 +-- .../Admin/d3webauthnadminloginTest.php | 9 +-- .../Controller/d3webauthnloginTest.php | 20 +++--- .../PublicKeyCredentialListTest.php | 10 +-- .../Credential/PublicKeyCredentialTest.php | 8 +-- .../WebauthnCreateExceptionTest.php | 2 +- .../Exceptions/WebauthnExceptionTest.php | 6 +- .../Exceptions/WebauthnGetExceptionTest.php | 2 +- .../Model/RelyingPartyEntityTest.php | 6 +- .../unit/Application/Model/UserEntityTest.php | 4 +- .../Model/WebauthnAfterLoginTest.php | 6 +- .../Application/Model/WebauthnErrorsTest.php | 4 +- .../Application/Model/WebauthnLoginTest.php | 21 +++--- .../unit/Application/Model/WebauthnTest.php | 18 ++--- .../Component/UserComponentWebauthnTest.php | 8 +-- .../Controller/AccountControllerTest.php | 2 +- .../AccountDownloadsControllerTest.php | 2 +- .../AccountNewsletterControllerTest.php | 2 +- .../AccountNoticeListControllerTest.php | 2 +- .../Controller/AccountOrderControllerTest.php | 2 +- .../AccountPasswordControllerTest.php | 2 +- .../AccountRecommlistControllerTest.php | 2 +- .../AccountReviewControllerTest.php | 2 +- .../Controller/AccountTestTrait.php | 2 +- .../Controller/AccountUserControllerTest.php | 2 +- .../AccountWishlistControllerTest.php | 2 +- .../Admin/LoginControllerWebauthnTest.php | 6 +- .../Controller/CheckoutTestTrait.php | 4 +- .../Controller/OrderControllerTest.php | 2 +- .../Controller/PaymentControllerTest.php | 2 +- .../Controller/UserControllerTest.php | 2 +- .../Application/Model/UserWebauthnTest.php | 7 +- src/tests/unit/Setup/ActionsTest.php | 4 +- 81 files changed, 271 insertions(+), 218 deletions(-) create mode 100644 .php-cs-fixer.php diff --git a/.gitignore b/.gitignore index 997cf12..058c4e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea +.php_cs.cache src/tests/.phpunit.result.cache src/tests/reports/ diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..0ce0b5e --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,13 @@ +in(__DIR__) +; + +$config = new PhpCsFixer\Config(); +return $config->setRules([ + '@PHP74Migration' => true, + '@PSR12' => true + ]) + ->setFinder($finder) +; \ No newline at end of file diff --git a/composer.json b/composer.json index 3f26dbd..e7c13dd 100644 --- a/composer.json +++ b/composer.json @@ -39,6 +39,7 @@ "ext-json": "*" }, "require-dev": { + "friendsofphp/php-cs-fixer": "^2.19", "phpstan/phpstan": "^1.8" }, "autoload": { diff --git a/src/Application/Controller/Admin/d3user_webauthn.php b/src/Application/Controller/Admin/d3user_webauthn.php index 5172ea2..b9679ab 100755 --- a/src/Application/Controller/Admin/d3user_webauthn.php +++ b/src/Application/Controller/Admin/d3user_webauthn.php @@ -78,7 +78,7 @@ class d3user_webauthn extends AdminDetailsController public function requestNewCredential(): void { try { - $this->setPageType( 'requestnew' ); + $this->setPageType('requestnew'); $this->setAuthnRegister(); } catch (Exception|ContainerExceptionInterface|NotFoundExceptionInterface|DoctrineDriverException $e) { $this->d3GetMockableRegistryObject(UtilsView::class)->addErrorToDisplay($e->getMessage()); @@ -97,16 +97,16 @@ class d3user_webauthn extends AdminDetailsController { try { $error = Registry::getRequest()->getRequestEscapedParameter('error'); - if ( strlen((string) $error) ) { + if (strlen((string) $error)) { /** @var WebauthnCreateException $e */ $e = oxNew(WebauthnCreateException::class, $error); throw $e; } $credential = Registry::getRequest()->getRequestEscapedParameter('credential'); - if ( strlen((string) $credential) ) { + if (strlen((string) $credential)) { $webauthn = $this->d3GetMockableOxNewObject(Webauthn::class); - $webauthn->saveAuthn($credential, Registry::getRequest()->getRequestEscapedParameter( 'keyname' ) ); + $webauthn->saveAuthn($credential, Registry::getRequest()->getRequestEscapedParameter('keyname')); } } catch (WebauthnException $e) { $this->d3GetMockableLogger()->error($e->getDetailedErrorMessage(), ['UserId' => $this->getEditObjectId()]); @@ -175,4 +175,4 @@ class d3user_webauthn extends AdminDetailsController $credential = $this->d3GetMockableOxNewObject(PublicKeyCredential::class); $credential->delete(Registry::getRequest()->getRequestEscapedParameter('deleteoxid')); } -} \ No newline at end of file +} diff --git a/src/Application/Controller/Admin/d3webauthnadminlogin.php b/src/Application/Controller/Admin/d3webauthnadminlogin.php index 466fcec..0a85d81 100755 --- a/src/Application/Controller/Admin/d3webauthnadminlogin.php +++ b/src/Application/Controller/Admin/d3webauthnadminlogin.php @@ -118,7 +118,8 @@ class d3webauthnadminlogin extends AdminController public function d3AssertAuthn(): ?string { try { - $login = $this->d3GetMockableOxNewObject(WebauthnLogin::class, + $login = $this->d3GetMockableOxNewObject( + WebauthnLogin::class, $this->d3GetMockableRegistryObject(Request::class)->getRequestEscapedParameter('credential'), $this->d3GetMockableRegistryObject(Request::class)->getRequestEscapedParameter('error') ); @@ -162,4 +163,4 @@ class d3webauthnadminlogin extends AdminController { return $this->previousClassIsOrderStep(); } -} \ No newline at end of file +} diff --git a/src/Application/Controller/Traits/accountTrait.php b/src/Application/Controller/Traits/accountTrait.php index 979d12e..155b69b 100644 --- a/src/Application/Controller/Traits/accountTrait.php +++ b/src/Application/Controller/Traits/accountTrait.php @@ -27,4 +27,4 @@ trait accountTrait parent::__construct(); } -} \ No newline at end of file +} diff --git a/src/Application/Controller/Traits/checkoutGetUserTrait.php b/src/Application/Controller/Traits/checkoutGetUserTrait.php index 9298dc7..ae46bfd 100755 --- a/src/Application/Controller/Traits/checkoutGetUserTrait.php +++ b/src/Application/Controller/Traits/checkoutGetUserTrait.php @@ -54,4 +54,4 @@ trait checkoutGetUserTrait return $user; } -} \ No newline at end of file +} diff --git a/src/Application/Controller/d3_account_webauthn.php b/src/Application/Controller/d3_account_webauthn.php index 619c992..be579ed 100755 --- a/src/Application/Controller/d3_account_webauthn.php +++ b/src/Application/Controller/d3_account_webauthn.php @@ -125,7 +125,7 @@ class d3_account_webauthn extends AccountController $error = Registry::getRequest()->getRequestEscapedParameter('error'); if (strlen((string) $error)) { /** @var WebauthnCreateException $e */ - $e = oxNew( WebauthnCreateException::class, $error); + $e = oxNew(WebauthnCreateException::class, $error); throw $e; } @@ -135,7 +135,7 @@ class d3_account_webauthn extends AccountController $webauthn->saveAuthn($credential, Registry::getRequest()->getRequestEscapedParameter('keyname')); } } catch (WebauthnException $e) { - $this->d3GetMockableRegistryObject(UtilsView::class)->addErrorToDisplay( $e ); + $this->d3GetMockableRegistryObject(UtilsView::class)->addErrorToDisplay($e); } } @@ -180,4 +180,4 @@ class d3_account_webauthn extends AccountController return $aPaths; } -} \ No newline at end of file +} diff --git a/src/Application/Controller/d3webauthnlogin.php b/src/Application/Controller/d3webauthnlogin.php index 527f205..932eef4 100755 --- a/src/Application/Controller/d3webauthnlogin.php +++ b/src/Application/Controller/d3webauthnlogin.php @@ -156,4 +156,4 @@ class d3webauthnlogin extends FrontendController return $aPaths; } -} \ No newline at end of file +} diff --git a/src/Application/Model/Credential/PublicKeyCredential.php b/src/Application/Model/Credential/PublicKeyCredential.php index e103aec..cc50ad5 100755 --- a/src/Application/Model/Credential/PublicKeyCredential.php +++ b/src/Application/Model/Credential/PublicKeyCredential.php @@ -49,7 +49,7 @@ class PublicKeyCredential extends BaseModel public function setName(string $name): void { $this->assign([ - 'name' => $name + 'name' => $name, ]); } @@ -67,7 +67,7 @@ class PublicKeyCredential extends BaseModel public function setCredentialId(string $credentialId): void { $this->assign([ - 'credentialid' => base64_encode($credentialId) + 'credentialid' => base64_encode($credentialId), ]); } @@ -85,7 +85,7 @@ class PublicKeyCredential extends BaseModel public function setUserId(string $userId): void { $this->assign([ - 'oxuserid' => $userId + 'oxuserid' => $userId, ]); } @@ -103,7 +103,7 @@ class PublicKeyCredential extends BaseModel public function setCredential(PublicKeyCredentialSource $credential): void { $this->assign([ - 'credential' => base64_encode(serialize($credential)) + 'credential' => base64_encode(serialize($credential)), ]); } @@ -182,4 +182,4 @@ class PublicKeyCredential extends BaseModel return strlen((string) $oxid) ? $oxid : null; } -} \ No newline at end of file +} diff --git a/src/Application/Model/Credential/PublicKeyCredentialList.php b/src/Application/Model/Credential/PublicKeyCredentialList.php index 66b0109..3754f40 100755 --- a/src/Application/Model/Credential/PublicKeyCredentialList.php +++ b/src/Application/Model/Credential/PublicKeyCredentialList.php @@ -162,4 +162,4 @@ class PublicKeyCredentialList extends ListModel implements PublicKeyCredentialSo $base = $this->getBaseObject(); $base->saveCredentialSource($publicKeyCredentialSource); } -} \ No newline at end of file +} diff --git a/src/Application/Model/Exceptions/WebauthnCreateException.php b/src/Application/Model/Exceptions/WebauthnCreateException.php index 8908cd9..e940553 100644 --- a/src/Application/Model/Exceptions/WebauthnCreateException.php +++ b/src/Application/Model/Exceptions/WebauthnCreateException.php @@ -23,4 +23,4 @@ class WebauthnCreateException extends WebauthnException { return WebauthnConf::TYPE_CREATE; } -} \ No newline at end of file +} diff --git a/src/Application/Model/Exceptions/WebauthnException.php b/src/Application/Model/Exceptions/WebauthnException.php index 236d1e7..587cb54 100644 --- a/src/Application/Model/Exceptions/WebauthnException.php +++ b/src/Application/Model/Exceptions/WebauthnException.php @@ -26,19 +26,19 @@ class WebauthnException extends StandardException public $detailedErrorMessage = null; - public function __construct( $sMessage = "not set", $iCode = 0, Exception $previous = null ) + public function __construct($sMessage = "not set", $iCode = 0, Exception $previous = null) { $this->setDetailedErrorMessage($sMessage); $this->d3CallMockableFunction( [ StandardException::class, - '__construct' + '__construct', ], [ $this->getErrorMessageTranslator()->translateError($sMessage, $this->getRequestType()), $iCode, - $previous + $previous, ] ); } @@ -75,4 +75,4 @@ class WebauthnException extends StandardException { $this->detailedErrorMessage = 'Webauthn: '.$detailedErrorMessage; } -} \ No newline at end of file +} diff --git a/src/Application/Model/Exceptions/WebauthnGetException.php b/src/Application/Model/Exceptions/WebauthnGetException.php index 38f0ac6..cab7677 100644 --- a/src/Application/Model/Exceptions/WebauthnGetException.php +++ b/src/Application/Model/Exceptions/WebauthnGetException.php @@ -23,4 +23,4 @@ class WebauthnGetException extends WebauthnException { return WebauthnConf::TYPE_GET; } -} \ No newline at end of file +} diff --git a/src/Application/Model/Exceptions/WebauthnLoginErrorException.php b/src/Application/Model/Exceptions/WebauthnLoginErrorException.php index f97a1f2..39711d0 100644 --- a/src/Application/Model/Exceptions/WebauthnLoginErrorException.php +++ b/src/Application/Model/Exceptions/WebauthnLoginErrorException.php @@ -19,4 +19,4 @@ use OxidEsales\Eshop\Core\Exception\StandardException; class WebauthnLoginErrorException extends StandardException { -} \ No newline at end of file +} diff --git a/src/Application/Model/RelyingPartyEntity.php b/src/Application/Model/RelyingPartyEntity.php index 167e416..1e85855 100755 --- a/src/Application/Model/RelyingPartyEntity.php +++ b/src/Application/Model/RelyingPartyEntity.php @@ -29,11 +29,11 @@ class RelyingPartyEntity extends PublicKeyCredentialRpEntity $this->d3CallMockableFunction( [ PublicKeyCredentialRpEntity::class, - '__construct' + '__construct', ], [ $this->getActiveShop()->getFieldData('oxname'), - $this->getRPShopUrl() + $this->getRPShopUrl(), ] ); } @@ -79,4 +79,4 @@ class RelyingPartyEntity extends PublicKeyCredentialRpEntity { return $this->d3GetMockableRegistryObject(Config::class)->getActiveShop(); } -} \ No newline at end of file +} diff --git a/src/Application/Model/UserEntity.php b/src/Application/Model/UserEntity.php index 517bead..f7aad41 100755 --- a/src/Application/Model/UserEntity.php +++ b/src/Application/Model/UserEntity.php @@ -39,13 +39,13 @@ class UserEntity extends PublicKeyCredentialUserEntity $this->d3CallMockableFunction( [ PublicKeyCredentialUserEntity::class, - '__construct' + '__construct', ], [ strtolower($user->getFieldData('oxusername')), $user->getId(), - $user->getFieldData('oxfname') . ' ' . $user->getFieldData('oxlname') + $user->getFieldData('oxfname') . ' ' . $user->getFieldData('oxlname'), ] ); } -} \ No newline at end of file +} diff --git a/src/Application/Model/Webauthn.php b/src/Application/Model/Webauthn.php index 7251dbc..bb1a237 100644 --- a/src/Application/Model/Webauthn.php +++ b/src/Application/Model/Webauthn.php @@ -56,7 +56,7 @@ class Webauthn !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on' || in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) || // is localhost - (isset($_SERVER['REMOTE_ADDR']) && preg_match('/.*\.localhost$/mi', $_SERVER['REMOTE_ADDR']) ) // localhost is TLD + (isset($_SERVER['REMOTE_ADDR']) && preg_match('/.*\.localhost$/mi', $_SERVER['REMOTE_ADDR'])) // localhost is TLD ) { return true; } @@ -123,7 +123,7 @@ class Webauthn */ protected function jsonEncode($creationOptions) { - return json_encode($creationOptions,JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + return json_encode($creationOptions, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); } /** @@ -225,9 +225,9 @@ class Webauthn try { $this->getServer()->loadAndCheckAssertionResponse( - html_entity_decode( $response ), + html_entity_decode($response), $this->d3GetMockableRegistryObject(Session::class) - ->getVariable( self::SESSION_ASSERTION_OPTIONS ), + ->getVariable(self::SESSION_ASSERTION_OPTIONS), $userEntity, $serverRequest ); @@ -308,4 +308,4 @@ class Webauthn return is_array($list) && count($list); } -} \ No newline at end of file +} diff --git a/src/Application/Model/WebauthnAfterLogin.php b/src/Application/Model/WebauthnAfterLogin.php index dbe420d..9f0efe9 100644 --- a/src/Application/Model/WebauthnAfterLogin.php +++ b/src/Application/Model/WebauthnAfterLogin.php @@ -78,4 +78,4 @@ class WebauthnAfterLogin $myUtilsServer->setOxCookie("oxidadminlanguage", $aLanguages[$iLang]->abbr, time() + 31536000); $language->setTplLanguage($iLang); } -} \ No newline at end of file +} diff --git a/src/Application/Model/WebauthnConf.php b/src/Application/Model/WebauthnConf.php index 4680ec2..edf2673 100755 --- a/src/Application/Model/WebauthnConf.php +++ b/src/Application/Model/WebauthnConf.php @@ -41,4 +41,4 @@ class WebauthnConf public const TYPE_CREATE = 'TYPECREATE'; public const TYPE_GET = 'TYPEGET'; -} \ No newline at end of file +} diff --git a/src/Application/Model/WebauthnErrors.php b/src/Application/Model/WebauthnErrors.php index 862ba63..121cead 100644 --- a/src/Application/Model/WebauthnErrors.php +++ b/src/Application/Model/WebauthnErrors.php @@ -59,7 +59,7 @@ class WebauthnErrors } if (strtoupper($msg) === self::UNSECURECONNECTION) { - return $lang->translateString($msg); + return $lang->translateString($msg); } return $lang->translateString('D3_WEBAUTHN_ERR_TECHNICALERROR', null, true); @@ -72,9 +72,9 @@ class WebauthnErrors public function getErrIdFromMessage(string $msg): string { if (is_int(strpos($msg, ':'))) { - return trim( strtolower( substr( $msg, 0, strpos( $msg, ':' ) ) ) ); + return trim(strtolower(substr($msg, 0, strpos($msg, ':')))); } return trim(strtolower($msg)); } -} \ No newline at end of file +} diff --git a/src/Application/Model/WebauthnLogin.php b/src/Application/Model/WebauthnLogin.php index 19d11fc..e0bf0b1 100644 --- a/src/Application/Model/WebauthnLogin.php +++ b/src/Application/Model/WebauthnLogin.php @@ -360,4 +360,4 @@ class WebauthnLogin $session->setVariable(WebauthnConf::WEBAUTHN_SESSION_AUTH, $this->getCredential()); $session->setVariable(WebauthnConf::OXID_FRONTEND_AUTH, $user->getId()); } -} \ No newline at end of file +} diff --git a/src/Application/translations/de/d3webauthn_lang.php b/src/Application/translations/de/d3webauthn_lang.php index b309493..018e453 100755 --- a/src/Application/translations/de/d3webauthn_lang.php +++ b/src/Application/translations/de/d3webauthn_lang.php @@ -16,7 +16,7 @@ $sLangName = 'Deutsch'; // ------------------------------- // RESOURCE IDENTIFIER = STRING // ------------------------------- -$aLang = array( +$aLang = [ 'charset' => 'UTF-8', 'PAGE_TITLE_D3WEBAUTHNLOGIN' => 'Passwortloses Anmelden', @@ -25,7 +25,7 @@ $aLang = array( 'D3_WEBAUTHN_ACCOUNT_DESC' => 'Verwalten Sie hier Ihre Anmeldeschlüssel.', 'D3_WEBAUTHN_ACC_REGISTERNEW' => 'neue Registrierung erstellen', 'D3_WEBAUTHN_ACC_ADDKEY' => 'Sicherheitsschlüssel hinzufügen', - + 'D3_WEBAUTHN_ACC_REGISTEREDKEYS' => 'registrierte Schlüssel', 'WEBAUTHN_INPUT_HELP' => 'Bitte mit Hardwareschlüssel authentisieren.', @@ -47,4 +47,4 @@ $aLang = array( 'D3_WEBAUTHN_ERR_UNSECURECONNECTION' => 'Die Verwendung von Sicherheitsschlüsseln ist nur bei lokalen oder gesicherten Verbindungen (https) möglich.', 'D3_WEBAUTHN_ERR_LOGINPROHIBITED' => 'Die Anmeldung mit Sicherheitsschlüssel ist aus technischen Gründen derzeit leider nicht möglich. Bitte verwenden Sie statt dessen Ihr Passwort.', 'D3_WEBAUTHN_ERR_NOTLOADEDUSER' => "Kann keine Anmeldedaten von nicht geladenem Kundenkonto beziehen.", -); +]; diff --git a/src/Application/views/admin/de/d3webauthn_lang.php b/src/Application/views/admin/de/d3webauthn_lang.php index 85874b0..006dc32 100755 --- a/src/Application/views/admin/de/d3webauthn_lang.php +++ b/src/Application/views/admin/de/d3webauthn_lang.php @@ -56,5 +56,5 @@ $aLang = [ '

Ist Ihr Shop unter verschiedenen Subdomains erreichbar, können Sie hier die Hauptdomain angeben, die zur Registrierung verwendet werden soll. Beachten Sie bitte, '. 'dass die hier angegebene Adresse mit der des Shopaufrufs übereinstimmen muss. Shopfremde Adressen werden bei der Verwendung abgelehnt.

'. '

Bleibt das Feld leer, wird die Adresse des aktuellen Shopaufrufs verwendet. Bei Verwendung unterschiedlicher Adressen muss vom Nutzer für jede Adresse eine separate '. - 'Schlüsselregistrierung durchgeführt werden.

' + 'Schlüsselregistrierung durchgeführt werden.

', ]; diff --git a/src/Application/views/admin/en/d3webauthn_lang.php b/src/Application/views/admin/en/d3webauthn_lang.php index 3f8cf43..565572e 100755 --- a/src/Application/views/admin/en/d3webauthn_lang.php +++ b/src/Application/views/admin/en/d3webauthn_lang.php @@ -57,5 +57,5 @@ $aLang = [ '

If your shop can be reached under different subdomains, you can enter the main domain here that is to be used for registration. Please '. 'note that the address given here must match the address of the shop call. Addresses that do not match the shop will be rejected.

'. '

If the field remains empty, the address of the current shop call is used. If different addresses are used, a separate key registration '. - 'must be carried out by the user for each address.

' + 'must be carried out by the user for each address.

', ]; diff --git a/src/IntelliSenseHelper.php b/src/IntelliSenseHelper.php index 4d567b3..b32c53d 100755 --- a/src/IntelliSenseHelper.php +++ b/src/IntelliSenseHelper.php @@ -15,7 +15,9 @@ namespace D3\Webauthn\Modules\Application\Component { use OxidEsales\Eshop\Application\Component\UserComponent; - class d3_webauthn_UserComponent_parent extends UserComponent {} + class d3_webauthn_UserComponent_parent extends UserComponent + { + } } namespace D3\Webauthn\Modules\Application\Controller @@ -35,44 +37,74 @@ namespace D3\Webauthn\Modules\Application\Controller use OxidEsales\Eshop\Application\Controller\PaymentController; use OxidEsales\Eshop\Application\Controller\UserController; - class d3_webauthn_UserController_parent extends UserController {} + class d3_webauthn_UserController_parent extends UserController + { + } - class d3_webauthn_OrderController_parent extends OrderController {} + class d3_webauthn_OrderController_parent extends OrderController + { + } - class d3_webauthn_PaymentController_parent extends PaymentController {} + class d3_webauthn_PaymentController_parent extends PaymentController + { + } /** workarounds for missing tpl blocks (https://github.com/OXID-eSales/wave-theme/pull/124) */ - class d3_AccountController_Webauthn_parent extends AccountController {} + class d3_AccountController_Webauthn_parent extends AccountController + { + } - class d3_AccountDownloadsController_Webauthn_parent extends AccountDownloadsController {} + class d3_AccountDownloadsController_Webauthn_parent extends AccountDownloadsController + { + } - class d3_AccountNoticeListController_Webauthn_parent extends AccountNoticeListController {} + class d3_AccountNoticeListController_Webauthn_parent extends AccountNoticeListController + { + } - class d3_AccountWishlistController_Webauthn_parent extends AccountWishlistController {} + class d3_AccountWishlistController_Webauthn_parent extends AccountWishlistController + { + } - class d3_AccountRecommlistController_Webauthn_parent extends AccountRecommlistController {} + class d3_AccountRecommlistController_Webauthn_parent extends AccountRecommlistController + { + } - class d3_AccountPasswordController_Webauthn_parent extends AccountPasswordController {} + class d3_AccountPasswordController_Webauthn_parent extends AccountPasswordController + { + } - class d3_AccountNewsletterController_Webauthn_parent extends AccountNewsletterController {} + class d3_AccountNewsletterController_Webauthn_parent extends AccountNewsletterController + { + } - class d3_AccountUserController_Webauthn_parent extends AccountUserController {} + class d3_AccountUserController_Webauthn_parent extends AccountUserController + { + } - class d3_AccountOrderController_Webauthn_parent extends AccountOrderController {} + class d3_AccountOrderController_Webauthn_parent extends AccountOrderController + { + } - class d3_AccountReviewController_Webauthn_parent extends AccountReviewController {} + class d3_AccountReviewController_Webauthn_parent extends AccountReviewController + { + } } namespace D3\Webauthn\Modules\Application\Controller\Admin { use OxidEsales\Eshop\Application\Controller\Admin\LoginController; - class d3_LoginController_Webauthn_parent extends LoginController {} + class d3_LoginController_Webauthn_parent extends LoginController + { + } } namespace D3\Webauthn\Modules\Application\Model { use OxidEsales\Eshop\Application\Model\User; - class d3_User_Webauthn_parent extends User {} -} \ No newline at end of file + class d3_User_Webauthn_parent extends User + { + } +} diff --git a/src/Modules/Application/Component/d3_webauthn_UserComponent.php b/src/Modules/Application/Component/d3_webauthn_UserComponent.php index 912e039..2410af5 100755 --- a/src/Modules/Application/Component/d3_webauthn_UserComponent.php +++ b/src/Modules/Application/Component/d3_webauthn_UserComponent.php @@ -58,12 +58,12 @@ class d3_webauthn_UserComponent extends d3_webauthn_UserComponent_parent */ public function d3WebauthnLogin(): void { - $lgn_user = $this->d3GetMockableRegistryObject(Request::class)->getRequestParameter( 'lgn_usr'); + $lgn_user = $this->d3GetMockableRegistryObject(Request::class)->getRequestParameter('lgn_usr'); /** @var d3_User_Webauthn $user */ $user = $this->d3GetMockableOxNewObject(User::class); $userId = $user->d3GetLoginUserId($lgn_user); - if ( $this->d3CanUseWebauthn( $lgn_user, $userId)) { + if ($this->d3CanUseWebauthn($lgn_user, $userId)) { if ($this->d3HasWebauthnButNotLoggedin($userId)) { $session = $this->d3GetMockableRegistryObject(Session::class); $session->setVariable( @@ -95,15 +95,15 @@ class d3_webauthn_UserComponent extends d3_webauthn_UserComponent_parent * * @return bool */ - protected function d3CanUseWebauthn( $lgn_user, ?string $userId): bool + protected function d3CanUseWebauthn($lgn_user, ?string $userId): bool { - $password = $this->d3GetMockableRegistryObject(Request::class)->getRequestParameter( 'lgn_pwd'); + $password = $this->d3GetMockableRegistryObject(Request::class)->getRequestParameter('lgn_pwd'); return $lgn_user && $userId && false === $this->d3GetMockableRegistryObject(Session::class) - ->hasVariable( WebauthnConf::WEBAUTHN_SESSION_AUTH ) && - ( ! strlen( trim( (string) $password ) ) ); + ->hasVariable(WebauthnConf::WEBAUTHN_SESSION_AUTH) && + (! strlen(trim((string) $password))); } /** @@ -147,7 +147,8 @@ class d3_webauthn_UserComponent extends d3_webauthn_UserComponent_parent public function d3AssertAuthn(): void { try { - $login = $this->d3GetMockableOxNewObject(WebauthnLogin::class, + $login = $this->d3GetMockableOxNewObject( + WebauthnLogin::class, $this->d3GetMockableRegistryObject(Request::class)->getRequestEscapedParameter('credential'), $this->d3GetMockableRegistryObject(Request::class)->getRequestEscapedParameter('error') ); @@ -158,6 +159,7 @@ class d3_webauthn_UserComponent extends d3_webauthn_UserComponent_parent $this->_afterLogin($this->getUser()); } catch (WebauthnGetException $e) { $this->d3GetMockableRegistryObject(UtilsView::class)->addErrorToDisplay($e); - } catch (WebauthnLoginErrorException $e) {} + } catch (WebauthnLoginErrorException $e) { + } } -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/Admin/d3_LoginController_Webauthn.php b/src/Modules/Application/Controller/Admin/d3_LoginController_Webauthn.php index fbfe111..dd6ec23 100755 --- a/src/Modules/Application/Controller/Admin/d3_LoginController_Webauthn.php +++ b/src/Modules/Application/Controller/Admin/d3_LoginController_Webauthn.php @@ -40,7 +40,7 @@ class d3_LoginController_Webauthn extends d3_LoginController_Webauthn_parent */ public function checklogin() { - $lgn_user = $this->d3GetMockableRegistryObject(Request::class)->getRequestParameter( 'user') ?: + $lgn_user = $this->d3GetMockableRegistryObject(Request::class)->getRequestParameter('user') ?: $this->d3GetMockableRegistryObject(Session::class) ->getVariable(WebauthnConf::WEBAUTHN_ADMIN_SESSION_LOGINUSER); @@ -48,16 +48,16 @@ class d3_LoginController_Webauthn extends d3_LoginController_Webauthn_parent $user = $this->d3GetMockableOxNewObject(User::class); $userId = $user->d3GetLoginUserId($lgn_user, 'malladmin'); - if ( $this->d3CanUseWebauthn( $lgn_user, $userId)) { + if ($this->d3CanUseWebauthn($lgn_user, $userId)) { $this->d3GetMockableRegistryObject(Session::class)->setVariable( WebauthnConf::WEBAUTHN_ADMIN_PROFILE, $this->d3GetMockableRegistryObject(Request::class) - ->getRequestEscapedParameter( 'profile') + ->getRequestEscapedParameter('profile') ); $this->d3GetMockableRegistryObject(Session::class)->setVariable( WebauthnConf::WEBAUTHN_ADMIN_CHLANGUAGE, $this->d3GetMockableRegistryObject(Request::class) - ->getRequestEscapedParameter( 'chlanguage') + ->getRequestEscapedParameter('chlanguage') ); if ($this->hasWebauthnButNotLoggedin($userId)) { @@ -96,15 +96,15 @@ class d3_LoginController_Webauthn extends d3_LoginController_Webauthn_parent * * @return bool */ - protected function d3CanUseWebauthn( $lgn_user, ?string $userId): bool + protected function d3CanUseWebauthn($lgn_user, ?string $userId): bool { - $password = $this->d3GetMockableRegistryObject(Request::class)->getRequestParameter( 'pwd'); + $password = $this->d3GetMockableRegistryObject(Request::class)->getRequestParameter('pwd'); return $lgn_user && $userId && false === $this->d3GetMockableRegistryObject(Session::class) - ->hasVariable( WebauthnConf::WEBAUTHN_ADMIN_SESSION_AUTH ) && - ( ! strlen( trim( (string) $password ) ) ); + ->hasVariable(WebauthnConf::WEBAUTHN_ADMIN_SESSION_AUTH) && + (! strlen(trim((string) $password))); } /** @@ -121,4 +121,4 @@ class d3_LoginController_Webauthn extends d3_LoginController_Webauthn_parent && !$this->d3GetMockableRegistryObject(Session::class) ->getVariable(WebauthnConf::WEBAUTHN_ADMIN_SESSION_AUTH); } -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/d3_AccountController_Webauthn.php b/src/Modules/Application/Controller/d3_AccountController_Webauthn.php index 698a186..5711ad4 100644 --- a/src/Modules/Application/Controller/d3_AccountController_Webauthn.php +++ b/src/Modules/Application/Controller/d3_AccountController_Webauthn.php @@ -21,4 +21,4 @@ use D3\Webauthn\Application\Controller\Traits\accountTrait; class d3_AccountController_Webauthn extends d3_AccountController_Webauthn_parent { use accountTrait; -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/d3_AccountDownloadsController_Webauthn.php b/src/Modules/Application/Controller/d3_AccountDownloadsController_Webauthn.php index 434336e..b2ffb73 100644 --- a/src/Modules/Application/Controller/d3_AccountDownloadsController_Webauthn.php +++ b/src/Modules/Application/Controller/d3_AccountDownloadsController_Webauthn.php @@ -21,4 +21,4 @@ use D3\Webauthn\Application\Controller\Traits\accountTrait; class d3_AccountDownloadsController_Webauthn extends d3_AccountDownloadsController_Webauthn_parent { use accountTrait; -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/d3_AccountNewsletterController_Webauthn.php b/src/Modules/Application/Controller/d3_AccountNewsletterController_Webauthn.php index da9f8e0..ad72eb1 100644 --- a/src/Modules/Application/Controller/d3_AccountNewsletterController_Webauthn.php +++ b/src/Modules/Application/Controller/d3_AccountNewsletterController_Webauthn.php @@ -21,4 +21,4 @@ use D3\Webauthn\Application\Controller\Traits\accountTrait; class d3_AccountNewsletterController_Webauthn extends d3_AccountNewsletterController_Webauthn_parent { use accountTrait; -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/d3_AccountNoticeListController_Webauthn.php b/src/Modules/Application/Controller/d3_AccountNoticeListController_Webauthn.php index a2a884c..ff09a8a 100644 --- a/src/Modules/Application/Controller/d3_AccountNoticeListController_Webauthn.php +++ b/src/Modules/Application/Controller/d3_AccountNoticeListController_Webauthn.php @@ -21,4 +21,4 @@ use D3\Webauthn\Application\Controller\Traits\accountTrait; class d3_AccountNoticeListController_Webauthn extends d3_AccountNoticeListController_Webauthn_parent { use accountTrait; -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/d3_AccountOrderController_Webauthn.php b/src/Modules/Application/Controller/d3_AccountOrderController_Webauthn.php index bdddb14..d665db0 100644 --- a/src/Modules/Application/Controller/d3_AccountOrderController_Webauthn.php +++ b/src/Modules/Application/Controller/d3_AccountOrderController_Webauthn.php @@ -21,4 +21,4 @@ use D3\Webauthn\Application\Controller\Traits\accountTrait; class d3_AccountOrderController_Webauthn extends d3_AccountOrderController_Webauthn_parent { use accountTrait; -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/d3_AccountPasswordController_Webauthn.php b/src/Modules/Application/Controller/d3_AccountPasswordController_Webauthn.php index dc8b696..7d3507b 100644 --- a/src/Modules/Application/Controller/d3_AccountPasswordController_Webauthn.php +++ b/src/Modules/Application/Controller/d3_AccountPasswordController_Webauthn.php @@ -21,4 +21,4 @@ use D3\Webauthn\Application\Controller\Traits\accountTrait; class d3_AccountPasswordController_Webauthn extends d3_AccountPasswordController_Webauthn_parent { use accountTrait; -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/d3_AccountRecommlistController_Webauthn.php b/src/Modules/Application/Controller/d3_AccountRecommlistController_Webauthn.php index 7d8dc11..618f857 100644 --- a/src/Modules/Application/Controller/d3_AccountRecommlistController_Webauthn.php +++ b/src/Modules/Application/Controller/d3_AccountRecommlistController_Webauthn.php @@ -21,4 +21,4 @@ use D3\Webauthn\Application\Controller\Traits\accountTrait; class d3_AccountRecommlistController_Webauthn extends d3_AccountRecommlistController_Webauthn_parent { use accountTrait; -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/d3_AccountReviewController_Webauthn.php b/src/Modules/Application/Controller/d3_AccountReviewController_Webauthn.php index ecd0978..f3cf949 100644 --- a/src/Modules/Application/Controller/d3_AccountReviewController_Webauthn.php +++ b/src/Modules/Application/Controller/d3_AccountReviewController_Webauthn.php @@ -21,4 +21,4 @@ use D3\Webauthn\Application\Controller\Traits\accountTrait; class d3_AccountReviewController_Webauthn extends d3_AccountReviewController_Webauthn_parent { use accountTrait; -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/d3_AccountUserController_Webauthn.php b/src/Modules/Application/Controller/d3_AccountUserController_Webauthn.php index dfb9f69..5650b6a 100644 --- a/src/Modules/Application/Controller/d3_AccountUserController_Webauthn.php +++ b/src/Modules/Application/Controller/d3_AccountUserController_Webauthn.php @@ -21,4 +21,4 @@ use D3\Webauthn\Application\Controller\Traits\accountTrait; class d3_AccountUserController_Webauthn extends d3_AccountUserController_Webauthn_parent { use accountTrait; -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/d3_AccountWishlistController_Webauthn.php b/src/Modules/Application/Controller/d3_AccountWishlistController_Webauthn.php index 6ff2862..a0e7530 100644 --- a/src/Modules/Application/Controller/d3_AccountWishlistController_Webauthn.php +++ b/src/Modules/Application/Controller/d3_AccountWishlistController_Webauthn.php @@ -21,4 +21,4 @@ use D3\Webauthn\Application\Controller\Traits\accountTrait; class d3_AccountWishlistController_Webauthn extends d3_AccountWishlistController_Webauthn_parent { use accountTrait; -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/d3_webauthn_OrderController.php b/src/Modules/Application/Controller/d3_webauthn_OrderController.php index 342435f..9aeaff3 100755 --- a/src/Modules/Application/Controller/d3_webauthn_OrderController.php +++ b/src/Modules/Application/Controller/d3_webauthn_OrderController.php @@ -22,4 +22,4 @@ class d3_webauthn_OrderController extends d3_webauthn_OrderController_parent use checkoutGetUserTrait; private $parentClass = d3_webauthn_OrderController_parent::class; -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/d3_webauthn_PaymentController.php b/src/Modules/Application/Controller/d3_webauthn_PaymentController.php index 93c7ff7..f915e90 100755 --- a/src/Modules/Application/Controller/d3_webauthn_PaymentController.php +++ b/src/Modules/Application/Controller/d3_webauthn_PaymentController.php @@ -22,4 +22,4 @@ class d3_webauthn_PaymentController extends d3_webauthn_PaymentController_parent use checkoutGetUserTrait; private $parentClass = d3_webauthn_PaymentController_parent::class; -} \ No newline at end of file +} diff --git a/src/Modules/Application/Controller/d3_webauthn_UserController.php b/src/Modules/Application/Controller/d3_webauthn_UserController.php index f01a970..6f4f163 100755 --- a/src/Modules/Application/Controller/d3_webauthn_UserController.php +++ b/src/Modules/Application/Controller/d3_webauthn_UserController.php @@ -22,4 +22,4 @@ class d3_webauthn_UserController extends d3_webauthn_UserController_parent use checkoutGetUserTrait; private $parentClass = d3_webauthn_UserController_parent::class; -} \ No newline at end of file +} diff --git a/src/Modules/Application/Model/d3_User_Webauthn.php b/src/Modules/Application/Model/d3_User_Webauthn.php index 1f25a50..1c48c75 100755 --- a/src/Modules/Application/Model/d3_User_Webauthn.php +++ b/src/Modules/Application/Model/d3_User_Webauthn.php @@ -99,7 +99,7 @@ class d3_User_Webauthn extends d3_User_Webauthn_parent $this, [ $userName, - $shopId + $shopId, ] ); } @@ -145,4 +145,4 @@ class d3_User_Webauthn extends d3_User_Webauthn_parent return $qb->execute()->fetchOne() ?: null; } -} \ No newline at end of file +} diff --git a/src/Setup/Actions.php b/src/Setup/Actions.php index 8192dd9..f54481f 100644 --- a/src/Setup/Actions.php +++ b/src/Setup/Actions.php @@ -139,8 +139,8 @@ class Actions public function clearCache() { try { - $oUtils = $this->d3GetMockableRegistryObject( Utils::class ); - $oUtils->resetTemplateCache( $this->getModuleTemplates() ); + $oUtils = $this->d3GetMockableRegistryObject(Utils::class); + $oUtils->resetTemplateCache($this->getModuleTemplates()); $oUtils->resetLanguageCache(); } catch (ContainerExceptionInterface|NotFoundExceptionInterface|ModuleConfigurationNotFoundException $e) { $this->d3GetMockableLogger()->error($e->getMessage(), [$this]); @@ -175,7 +175,7 @@ class Actions { /** @var $template ModuleConfiguration\Template */ return array_map( - function($template) { + function ($template) { return $template->getTemplateKey(); }, $moduleConfiguration->getTemplates() @@ -191,7 +191,7 @@ class Actions { /** @var $templateBlock ModuleConfiguration\TemplateBlock */ return array_map( - function($templateBlock) { + function ($templateBlock) { return basename($templateBlock->getShopTemplatePath()); }, $moduleConfiguration->getTemplateBlocks() @@ -261,4 +261,4 @@ class Actions { return ContainerFactory::getInstance()->getContainer(); } -} \ No newline at end of file +} diff --git a/src/Setup/Events.php b/src/Setup/Events.php index a3d1a6c..d657816 100755 --- a/src/Setup/Events.php +++ b/src/Setup/Events.php @@ -47,4 +47,4 @@ class Events public static function onDeactivate(): void { } -} \ No newline at end of file +} diff --git a/src/metadata.php b/src/metadata.php index fed68d4..cd27a44 100755 --- a/src/metadata.php +++ b/src/metadata.php @@ -61,7 +61,7 @@ $logo = '