2019-07-31 22:43:34 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2022-09-26 15:22:26 +02:00
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
* https://www.d3data.de
|
2019-07-31 22:43:34 +02:00
|
|
|
*
|
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
2022-09-26 15:22:26 +02:00
|
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
|
|
* @link https://www.oxidmodule.com
|
2019-07-31 22:43:34 +02:00
|
|
|
*/
|
|
|
|
|
2022-09-28 00:08:36 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-07-31 22:43:34 +02:00
|
|
|
namespace D3\Totp\Application\Controller;
|
|
|
|
|
|
|
|
use D3\Totp\Application\Model\d3backupcodelist;
|
2022-11-10 00:00:50 +01:00
|
|
|
use D3\Totp\Application\Model\d3totp_conf;
|
2019-07-31 22:43:34 +02:00
|
|
|
use OxidEsales\Eshop\Application\Controller\FrontendController;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
|
|
|
use OxidEsales\Eshop\Core\Registry;
|
2019-08-05 22:59:26 +02:00
|
|
|
use OxidEsales\Eshop\Core\Utils;
|
2019-07-31 22:43:34 +02:00
|
|
|
|
|
|
|
class d3totplogin extends FrontendController
|
|
|
|
{
|
|
|
|
protected $_sThisTemplate = 'd3totplogin.tpl';
|
|
|
|
|
|
|
|
public function render()
|
|
|
|
{
|
2022-11-10 11:34:05 +01:00
|
|
|
if (false == Registry::getSession()->hasVariable(d3totp_conf::SESSION_CURRENTUSER)) {
|
2022-09-28 00:08:36 +02:00
|
|
|
$this->getUtils()->redirect('index.php?cl=start');
|
2019-08-05 22:59:26 +02:00
|
|
|
if (false == defined('OXID_PHP_UNIT')) {
|
2019-08-09 23:10:04 +02:00
|
|
|
// @codeCoverageIgnoreStart
|
2019-08-05 22:59:26 +02:00
|
|
|
exit;
|
2019-08-09 23:10:04 +02:00
|
|
|
// @codeCoverageIgnoreEnd
|
2019-08-05 22:59:26 +02:00
|
|
|
}
|
2019-07-31 22:43:34 +02:00
|
|
|
}
|
|
|
|
|
2022-11-10 00:00:50 +01:00
|
|
|
$this->addTplParam('navFormParams', Registry::getSession()->getVariable(d3totp_conf::SESSION_NAVFORMPARAMS));
|
2019-07-31 22:43:34 +02:00
|
|
|
|
|
|
|
return parent::render();
|
|
|
|
}
|
|
|
|
|
2019-08-05 22:59:26 +02:00
|
|
|
/**
|
|
|
|
* @return Utils
|
|
|
|
*/
|
2022-10-01 14:44:36 +02:00
|
|
|
public function getUtils(): Utils
|
2019-08-05 22:59:26 +02:00
|
|
|
{
|
|
|
|
return Registry::getUtils();
|
|
|
|
}
|
|
|
|
|
2019-07-31 22:43:34 +02:00
|
|
|
/**
|
|
|
|
* @return string|void
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
*/
|
|
|
|
public function getBackupCodeCountMessage()
|
|
|
|
{
|
2019-08-05 22:59:26 +02:00
|
|
|
$oBackupCodeList = $this->getBackupCodeListObject();
|
2022-11-10 11:34:05 +01:00
|
|
|
$userId = Registry::getSession()->getVariable(d3totp_conf::SESSION_CURRENTUSER);
|
|
|
|
$iCount = $oBackupCodeList->getAvailableCodeCount($userId);
|
2019-07-31 22:43:34 +02:00
|
|
|
|
|
|
|
if ($iCount < 4) {
|
|
|
|
return sprintf(
|
|
|
|
Registry::getLang()->translateString('D3_TOTP_AVAILBACKUPCODECOUNT', null, true),
|
|
|
|
$iCount
|
|
|
|
);
|
2022-09-28 00:08:36 +02:00
|
|
|
}
|
2019-07-31 22:43:34 +02:00
|
|
|
}
|
|
|
|
|
2019-08-05 22:59:26 +02:00
|
|
|
/**
|
|
|
|
* @return d3backupcodelist
|
|
|
|
*/
|
2022-10-01 14:44:36 +02:00
|
|
|
public function getBackupCodeListObject(): d3backupcodelist
|
2019-08-05 22:59:26 +02:00
|
|
|
{
|
|
|
|
return oxNew(d3backupcodelist::class);
|
|
|
|
}
|
|
|
|
|
2019-07-31 22:43:34 +02:00
|
|
|
public function getPreviousClass()
|
|
|
|
{
|
2022-11-10 00:00:50 +01:00
|
|
|
return Registry::getSession()->getVariable(d3totp_conf::SESSION_CURRENTCLASS);
|
2019-07-31 22:43:34 +02:00
|
|
|
}
|
|
|
|
|
2022-10-01 14:44:36 +02:00
|
|
|
public function previousClassIsOrderStep(): bool
|
2019-07-31 22:43:34 +02:00
|
|
|
{
|
2022-11-10 00:00:50 +01:00
|
|
|
$sClassKey = Registry::getSession()->getVariable(d3totp_conf::SESSION_CURRENTCLASS);
|
2019-07-31 22:43:34 +02:00
|
|
|
$resolvedClass = Registry::getControllerClassNameResolver()->getClassNameById($sClassKey);
|
2022-09-28 00:08:36 +02:00
|
|
|
$resolvedClass = $resolvedClass ?: 'start';
|
2019-07-31 22:43:34 +02:00
|
|
|
|
|
|
|
/** @var FrontendController $oController */
|
|
|
|
$oController = oxNew($resolvedClass);
|
|
|
|
return $oController->getIsOrderStep();
|
|
|
|
}
|
2019-08-02 00:23:21 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
2022-10-01 14:44:36 +02:00
|
|
|
public function getIsOrderStep(): bool
|
2019-08-02 00:23:21 +02:00
|
|
|
{
|
|
|
|
return $this->previousClassIsOrderStep();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns Bread Crumb - you are here page1/page2/page3...
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2022-10-01 14:44:36 +02:00
|
|
|
public function getBreadCrumb(): array
|
2019-08-02 00:23:21 +02:00
|
|
|
{
|
|
|
|
$aPaths = [];
|
|
|
|
$aPath = [];
|
2022-10-01 14:44:36 +02:00
|
|
|
$iBaseLanguage = (int) Registry::getLang()->getBaseLanguage();
|
2019-08-02 00:23:21 +02:00
|
|
|
$aPath['title'] = Registry::getLang()->translateString('D3_TOTP_BREADCRUMB', $iBaseLanguage, false);
|
|
|
|
$aPath['link'] = $this->getLink();
|
|
|
|
|
|
|
|
$aPaths[] = $aPath;
|
|
|
|
|
|
|
|
return $aPaths;
|
|
|
|
}
|
2022-09-30 21:06:30 +02:00
|
|
|
}
|