diff --git a/src/Application/Controller/Admin/d3user_totp.php b/src/Application/Controller/Admin/d3user_totp.php index 2e71031..38ec75d 100644 --- a/src/Application/Controller/Admin/d3user_totp.php +++ b/src/Application/Controller/Admin/d3user_totp.php @@ -31,7 +31,7 @@ class d3user_totp extends AdminDetailsController protected $_sThisTemplate = 'd3user_totp.tpl'; - public $aBackupCodes = array(); + public $aBackupCodes = []; /** * @return string @@ -104,6 +104,9 @@ class d3user_totp extends AdminDetailsController } } + /** + * @throws DatabaseConnectionException + */ public function delete() { $aParams = Registry::getRequest()->getRequestEscapedParameter("editval"); diff --git a/src/Application/Controller/d3totplogin.php b/src/Application/Controller/d3totplogin.php index d70ecae..958934c 100644 --- a/src/Application/Controller/d3totplogin.php +++ b/src/Application/Controller/d3totplogin.php @@ -28,13 +28,13 @@ class d3totplogin extends FrontendController public function render() { if (Registry::getSession()->hasVariable(d3totp::TOTP_SESSION_VARNAME) || - false == Registry::getSession()->hasVariable('d3totpCurrentUser') + false == Registry::getSession()->hasVariable(d3totp::TOTP_SESSION_CURRENTUSER) ) { Registry::getUtils()->redirect('index.php?cl=start', true, 302); exit; } - $this->addTplParam('navFormParams', Registry::getSession()->getVariable('d3totpNavFormParams')); + $this->addTplParam('navFormParams', Registry::getSession()->getVariable(d3totp::TOTP_SESSION_NAVFORMPARAMS)); return parent::render(); } @@ -46,7 +46,7 @@ class d3totplogin extends FrontendController public function getBackupCodeCountMessage() { $oBackupCodeList = oxNew(d3backupcodelist::class); - $iCount = $oBackupCodeList->getAvailableCodeCount(Registry::getSession()->getVariable('d3totpCurrentUser')); + $iCount = $oBackupCodeList->getAvailableCodeCount(Registry::getSession()->getVariable(d3totp::TOTP_SESSION_CURRENTUSER)); if ($iCount < 4) { return sprintf( @@ -60,12 +60,12 @@ class d3totplogin extends FrontendController public function getPreviousClass() { - return Registry::getSession()->getVariable('d3totpCurrentClass'); + return Registry::getSession()->getVariable(d3totp::TOTP_SESSION_CURRENTCLASS); } public function previousClassIsOrderStep() { - $sClassKey = Registry::getSession()->getVariable('d3totpCurrentClass'); + $sClassKey = Registry::getSession()->getVariable(d3totp::TOTP_SESSION_CURRENTCLASS); $resolvedClass = Registry::getControllerClassNameResolver()->getClassNameById($sClassKey); $resolvedClass = $resolvedClass ? $resolvedClass : 'start'; @@ -73,4 +73,30 @@ class d3totplogin extends FrontendController $oController = oxNew($resolvedClass); return $oController->getIsOrderStep(); } + + /** + * @return bool + */ + public function getIsOrderStep() + { + return $this->previousClassIsOrderStep(); + } + + /** + * Returns Bread Crumb - you are here page1/page2/page3... + * + * @return array + */ + public function getBreadCrumb() + { + $aPaths = []; + $aPath = []; + $iBaseLanguage = Registry::getLang()->getBaseLanguage(); + $aPath['title'] = Registry::getLang()->translateString('D3_TOTP_BREADCRUMB', $iBaseLanguage, false); + $aPath['link'] = $this->getLink(); + + $aPaths[] = $aPath; + + return $aPaths; + } } \ No newline at end of file diff --git a/src/Application/Model/d3backupcode.php b/src/Application/Model/d3backupcode.php index c21e515..af8356c 100644 --- a/src/Application/Model/d3backupcode.php +++ b/src/Application/Model/d3backupcode.php @@ -39,10 +39,10 @@ class d3backupcode extends BaseModel $sCode = $generator->generateString(6, Generator::CHAR_DIGITS); $this->assign( - array( + [ 'oxuserid' => $sUserId, 'backupcode' => $this->d3EncodeBC($sCode), - ) + ] ); return $sCode; @@ -68,7 +68,7 @@ class d3backupcode extends BaseModel return $this->getUser(); } - $sUserId = Registry::getSession()->getVariable('d3totpCurrentUser'); + $sUserId = Registry::getSession()->getVariable(d3totp::TOTP_SESSION_CURRENTUSER); $oUser = oxNew(User::class); $oUser->load($sUserId); return $oUser; diff --git a/src/Application/Model/d3backupcodelist.php b/src/Application/Model/d3backupcodelist.php index 89947d3..b0b9d07 100644 --- a/src/Application/Model/d3backupcodelist.php +++ b/src/Application/Model/d3backupcodelist.php @@ -16,9 +16,7 @@ namespace D3\Totp\Application\Model; use D3\Totp\Application\Controller\Admin\d3user_totp; -use D3\Totp\Application\Model\d3backupcode; use Exception; -use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Core\DatabaseProvider; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Model\ListModel; @@ -35,7 +33,7 @@ class d3backupcodelist extends ListModel */ protected $_sCoreTable = 'd3totp_backupcodes'; - protected $_backupCodes = array(); + protected $_backupCodes = []; /** * @param $sUserId @@ -134,13 +132,6 @@ class d3backupcodelist extends ListModel public function d3GetUser() { - if ($this->getUser()) { - return $this->getUser(); - } - - $sUserId = Registry::getSession()->getVariable('d3totpCurrentUser'); - $oUser = oxNew(User::class); - $oUser->load($sUserId); - return $oUser; + return $this->getBaseObject()->d3GetUser(); } } \ No newline at end of file diff --git a/src/Application/Model/d3totp.php b/src/Application/Model/d3totp.php index 3ea275c..bab1ad5 100644 --- a/src/Application/Model/d3totp.php +++ b/src/Application/Model/d3totp.php @@ -29,7 +29,10 @@ use OxidEsales\Eshop\Core\Registry; class d3totp extends BaseModel { - const TOTP_SESSION_VARNAME = 'totp_auth'; + const TOTP_SESSION_VARNAME = 'totp_auth'; + const TOTP_SESSION_CURRENTUSER = 'd3totpCurrentUser'; + const TOTP_SESSION_CURRENTCLASS = 'd3totpCurrentClass'; + const TOTP_SESSION_NAVFORMPARAMS = 'd3totpNavFormParams'; public $tableName = 'd3totp'; public $userId; @@ -175,9 +178,9 @@ class d3totp extends BaseModel public function saveSecret($seed) { $this->assign( - array( + [ 'seed' => $this->encrypt($seed) - ) + ] ); } diff --git a/src/Application/translations/de/d3_totp_lang.php b/src/Application/translations/de/d3_totp_lang.php index 742398e..a35d67b 100644 --- a/src/Application/translations/de/d3_totp_lang.php +++ b/src/Application/translations/de/d3_totp_lang.php @@ -17,10 +17,14 @@ $sLangName = "Deutsch"; -$aLang = array( +$aLang = [ 'charset' => 'UTF-8', - 'TOTP_INPUT' => 'Authentisierungscode', - 'TOTP_INPUT_HELP' => 'Das Einmalpasswort erhalten Sie von der Zweifaktorauthentisierung-App auf Ihrem Gerät.', - 'TOTP_CANCEL_LOGIN' => 'Anmeldung abbrechen', -); + 'D3_TOTP_INPUT' => 'Authentisierungscode', + 'D3_TOTP_INPUT_HELP' => 'Das Einmalpasswort erhalten Sie von der Zweifaktorauthentisierung-App auf Ihrem Gerät.', + 'D3_TOTP_SUBMIT_LOGIN' => 'Anmelden', + 'D3_TOTP_CANCEL_LOGIN' => 'Anmeldung abbrechen', + 'D3_TOTP_BREADCRUMB' => 'Einmalpasswort-Anmeldung', + 'D3_TOTP_ERROR_UNVALID' => 'Das Einmalpasswort ist ungültig.', + 'D3_TOTP_ACCOUNT' => '2-Faktor-Authentisierung', +]; diff --git a/src/Application/views/blocks/page/account/inc/account_menu.tpl b/src/Application/views/blocks/page/account/inc/account_menu.tpl new file mode 100644 index 0000000..15c8821 --- /dev/null +++ b/src/Application/views/blocks/page/account/inc/account_menu.tpl @@ -0,0 +1,4 @@ +[{$smarty.block.parent}] +