From a809c04b5bca500da03a131031173e79d1d4206b Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Thu, 24 Nov 2022 20:27:07 +0100 Subject: [PATCH] set selected language for otp form --- src/Application/Controller/Admin/d3totpadminlogin.php | 4 ++++ src/Application/Controller/d3totplogin.php | 7 +------ .../Controller/Admin/d3_totp_LoginController.php | 9 +++++++-- src/Modules/Core/d3_totp_utils.php | 10 ---------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/Application/Controller/Admin/d3totpadminlogin.php b/src/Application/Controller/Admin/d3totpadminlogin.php index d8d1f90..0135ca7 100644 --- a/src/Application/Controller/Admin/d3totpadminlogin.php +++ b/src/Application/Controller/Admin/d3totpadminlogin.php @@ -90,6 +90,10 @@ class d3totpadminlogin extends AdminController $this->addTplParam('selectedProfile', Registry::getRequest()->getRequestEscapedParameter('profile')); $this->addTplParam('selectedChLanguage', Registry::getRequest()->getRequestEscapedParameter('chlanguage')); + /** @var d3_totp_LoginController $loginController */ + $loginController = oxNew(LoginController::class); + $loginController->d3totpAfterLoginSetLanguage(); + return parent::render(); } diff --git a/src/Application/Controller/d3totplogin.php b/src/Application/Controller/d3totplogin.php index ae461f5..43d53f1 100644 --- a/src/Application/Controller/d3totplogin.php +++ b/src/Application/Controller/d3totplogin.php @@ -28,13 +28,8 @@ class d3totplogin extends FrontendController public function render() { - if (false == Registry::getSession()->hasVariable(d3totp_conf::SESSION_CURRENTUSER)) { + if (!Registry::getSession()->hasVariable(d3totp_conf::SESSION_CURRENTUSER)) { $this->getUtils()->redirect('index.php?cl=start'); - if (false == defined('OXID_PHP_UNIT')) { - // @codeCoverageIgnoreStart - exit; - // @codeCoverageIgnoreEnd - } } $this->addTplParam('navFormParams', Registry::getSession()->getVariable(d3totp_conf::SESSION_NAVFORMPARAMS)); diff --git a/src/Modules/Application/Controller/Admin/d3_totp_LoginController.php b/src/Modules/Application/Controller/Admin/d3_totp_LoginController.php index 59be402..9fedd96 100644 --- a/src/Modules/Application/Controller/Admin/d3_totp_LoginController.php +++ b/src/Modules/Application/Controller/Admin/d3_totp_LoginController.php @@ -82,7 +82,13 @@ class d3_totp_LoginController extends d3_totp_LoginController_parent $myUtilsServer->setOxCookie("oxidadminprofile", "", time() - 3600, "/"); } - // languages + $this->d3totpAfterLoginSetLanguage(); + Registry::getSession()->deleteVariable(d3totp_conf::SESSION_ADMIN_CHLANGUAGE); + } + + public function d3totpAfterLoginSetLanguage() + { + $myUtilsServer = Registry::getUtilsServer(); $iLang = Registry::getSession()->getVariable(d3totp_conf::SESSION_ADMIN_CHLANGUAGE); $aLanguages = Registry::getLang()->getAdminTplLanguageArray(); @@ -92,7 +98,6 @@ class d3_totp_LoginController extends d3_totp_LoginController_parent $myUtilsServer->setOxCookie("oxidadminlanguage", $aLanguages[$iLang]->abbr, time() + 31536000, "/"); Registry::getLang()->setTplLanguage($iLang); - Registry::getSession()->deleteVariable(d3totp_conf::SESSION_ADMIN_CHLANGUAGE); } /** diff --git a/src/Modules/Core/d3_totp_utils.php b/src/Modules/Core/d3_totp_utils.php index b24d343..88434a3 100644 --- a/src/Modules/Core/d3_totp_utils.php +++ b/src/Modules/Core/d3_totp_utils.php @@ -47,21 +47,11 @@ class d3_totp_utils extends d3_totp_utils_parent && $totp->isActive() === false ) { $this->redirect('index.php?cl=d3force_2fa'); - if (false == defined('OXID_PHP_UNIT')) { - // @codeCoverageIgnoreStart - exit; - // @codeCoverageIgnoreEnd - } } //staten der prüfung vom einmalpasswort if ($blAuth && $totp->isActive() && false === $totpAuth) { $this->redirect('index.php?cl=d3totpadminlogin'); - if (false == defined('OXID_PHP_UNIT')) { - // @codeCoverageIgnoreStart - exit; - // @codeCoverageIgnoreEnd - } } return $blAuth;