From 2bf7399aa48ed5e5b3d7489e973859f4260ea04e Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 8 Nov 2022 22:47:11 +0100 Subject: [PATCH] move webauthn check to deeper implemented login method --- .../Component/d3_webauthn_UserComponent.php | 11 ++++++----- src/tests/integration/passwordFrontendAuthTest.php | 13 ++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Modules/Application/Component/d3_webauthn_UserComponent.php b/src/Modules/Application/Component/d3_webauthn_UserComponent.php index b48436e..8aff3f1 100755 --- a/src/Modules/Application/Component/d3_webauthn_UserComponent.php +++ b/src/Modules/Application/Component/d3_webauthn_UserComponent.php @@ -33,13 +33,13 @@ use Psr\Container\NotFoundExceptionInterface; class d3_webauthn_UserComponent extends d3_webauthn_UserComponent_parent { /** - * @return string|void + * @return string * @throws ContainerExceptionInterface * @throws Exception * @throws NotFoundExceptionInterface * @throws DoctrineDriverException */ - public function login_noredirect() + public function login() { $lgn_user = Registry::getRequest()->getRequestParameter('lgn_usr'); $password = Registry::getRequest()->getRequestParameter('lgn_pwd'); @@ -70,11 +70,12 @@ class d3_webauthn_UserComponent extends d3_webauthn_UserComponent_parent $this->getParent()->getViewConfig()->getNavFormParams() ); - return "d3webauthnlogin"; + $sUrl = $this->getConfig()->getShopHomeUrl() . 'cl=d3webauthnlogin'; + Registry::getUtils()->redirect($sUrl, true, 302); } } - parent::login_noredirect(); + return parent::login(); } /** @@ -102,7 +103,7 @@ class d3_webauthn_UserComponent extends d3_webauthn_UserComponent_parent * @param User $user * @param $sWebauthn */ - public function d3WebauthnRelogin(User $user, $sWebauthn): void + protected function d3WebauthnRelogin(User $user, $sWebauthn): void { $setSessionCookie = Registry::getRequest()->getRequestParameter('lgn_cook'); $this->d3GetSession()->setVariable(WebauthnConf::WEBAUTHN_SESSION_AUTH, $sWebauthn); diff --git a/src/tests/integration/passwordFrontendAuthTest.php b/src/tests/integration/passwordFrontendAuthTest.php index 73e36bf..6aafe1e 100644 --- a/src/tests/integration/passwordFrontendAuthTest.php +++ b/src/tests/integration/passwordFrontendAuthTest.php @@ -86,11 +86,10 @@ class passwordFrontendAuthTest extends integrationTestCase $controller->init(); /** @var d3_webauthn_UserComponent $component */ $component = $controller->getComponent('oxcmp_user'); - $component->login_noredirect(); $this->assertSame( $expected, - $component->getLoginStatus() + $component->login() ); $component->logout(); @@ -102,11 +101,11 @@ class passwordFrontendAuthTest extends integrationTestCase public function loginDataProvider(): array { return [ - 'not existing account' => ['unknown@user.localhost', '123456', USER_LOGIN_FAIL], - 'missing password' => ['noadmin@user.localhost', null, USER_LOGIN_FAIL], - 'inactive account' => ['inactive@user.localhost', '123456', USER_LOGIN_FAIL], - 'wrong shop account' => ['wrongshop@user.localhost', '123456', USER_LOGIN_FAIL], - 'account ok' => ['noadmin@user.localhost', '123456', USER_LOGIN_SUCCESS], + 'not existing account' => ['unknown@user.localhost', '123456', 'user'], + 'missing password' => ['noadmin@user.localhost', null, 'user'], + 'inactive account' => ['inactive@user.localhost', '123456', 'user'], + 'wrong shop account' => ['wrongshop@user.localhost', '123456', 'user'], + 'account ok' => ['noadmin@user.localhost', '123456', 'payment'], ]; } } \ No newline at end of file