get module setting from service
This commit is contained in:
parent
12d47d14f0
commit
e509aa7eff
@ -4,13 +4,20 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace D3\Totp\Application\Controller\Admin;
|
namespace D3\Totp\Application\Controller\Admin;
|
||||||
|
|
||||||
|
use D3\Totp\Application\Model\Constants;
|
||||||
use D3\Totp\Application\Model\d3totp_conf;
|
use D3\Totp\Application\Model\d3totp_conf;
|
||||||
use OxidEsales\Eshop\Core\Registry;
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
use OxidEsales\Eshop\Core\Session;
|
use OxidEsales\Eshop\Core\Session;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridgeInterface;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleSettingNotFountException;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
|
||||||
class d3force_2fa extends d3user_totp
|
class d3force_2fa extends d3user_totp
|
||||||
{
|
{
|
||||||
public function render()
|
public function render(): string
|
||||||
{
|
{
|
||||||
$this->addTplParam('force2FA', true);
|
$this->addTplParam('force2FA', true);
|
||||||
|
|
||||||
@ -21,7 +28,7 @@ class d3force_2fa extends d3user_totp
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function _authorize()
|
protected function authorize(): bool
|
||||||
{
|
{
|
||||||
$userID = $this->d3TotpGetSessionObject()->getVariable(d3totp_conf::OXID_ADMIN_AUTH);
|
$userID = $this->d3TotpGetSessionObject()->getVariable(d3totp_conf::OXID_ADMIN_AUTH);
|
||||||
|
|
||||||
@ -31,17 +38,27 @@ class d3force_2fa extends d3user_totp
|
|||||||
/**
|
/**
|
||||||
* @return Session
|
* @return Session
|
||||||
*/
|
*/
|
||||||
private function d3TotpGetSessionObject()
|
private function d3TotpGetSessionObject(): Session
|
||||||
{
|
{
|
||||||
return Registry::getSession();
|
return Registry::getSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws ModuleSettingNotFountException
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
private function d3IsAdminForce2FA()
|
private function d3IsAdminForce2FA(): bool
|
||||||
{
|
{
|
||||||
return $this->isAdmin() &&
|
if (!$this->isAdmin()) {
|
||||||
Registry::getConfig()->getConfigParam('D3_TOTP_ADMIN_FORCE_2FA') == true;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$container = ContainerFactory::getInstance()->getContainer();
|
||||||
|
$moduleConfigurationBridge = $container->get(ModuleConfigurationDaoBridgeInterface::class);
|
||||||
|
/** @var ModuleConfiguration $moduleConfiguration */
|
||||||
|
$moduleConfiguration = $moduleConfigurationBridge->get(Constants::OXID_MODULE_ID);
|
||||||
|
return (bool) $moduleConfiguration->getModuleSetting('D3_TOTP_ADMIN_FORCE_2FA')->getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace D3\Totp\Modules\Core;
|
namespace D3\Totp\Modules\Core;
|
||||||
|
|
||||||
|
use D3\Totp\Application\Model\Constants;
|
||||||
use D3\Totp\Application\Model\d3totp;
|
use D3\Totp\Application\Model\d3totp;
|
||||||
use D3\Totp\Application\Model\d3totp_conf;
|
use D3\Totp\Application\Model\d3totp_conf;
|
||||||
use Doctrine\DBAL\DBALException;
|
use Doctrine\DBAL\DBALException;
|
||||||
@ -22,6 +23,12 @@ use OxidEsales\Eshop\Core\Config;
|
|||||||
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
||||||
use OxidEsales\Eshop\Core\Registry;
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
use OxidEsales\Eshop\Core\Session;
|
use OxidEsales\Eshop\Core\Session;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridgeInterface;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleSettingNotFountException;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
|
||||||
class d3_totp_utils extends d3_totp_utils_parent
|
class d3_totp_utils extends d3_totp_utils_parent
|
||||||
{
|
{
|
||||||
@ -60,7 +67,7 @@ class d3_totp_utils extends d3_totp_utils_parent
|
|||||||
/**
|
/**
|
||||||
* @return Session
|
* @return Session
|
||||||
*/
|
*/
|
||||||
public function d3TotpGetSessionObject()
|
public function d3TotpGetSessionObject(): Session
|
||||||
{
|
{
|
||||||
return Registry::getSession();
|
return Registry::getSession();
|
||||||
}
|
}
|
||||||
@ -68,7 +75,7 @@ class d3_totp_utils extends d3_totp_utils_parent
|
|||||||
/**
|
/**
|
||||||
* @return d3totp
|
* @return d3totp
|
||||||
*/
|
*/
|
||||||
public function d3GetTotpObject()
|
public function d3GetTotpObject(): d3totp
|
||||||
{
|
{
|
||||||
return oxNew(d3totp::class);
|
return oxNew(d3totp::class);
|
||||||
}
|
}
|
||||||
@ -83,11 +90,21 @@ class d3_totp_utils extends d3_totp_utils_parent
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws ModuleSettingNotFountException
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
protected function d3IsAdminForce2FA()
|
protected function d3IsAdminForce2FA(): bool
|
||||||
{
|
{
|
||||||
return $this->isAdmin() &&
|
if (!$this->isAdmin()) {
|
||||||
$this->d3GetConfig()->getConfigParam('D3_TOTP_ADMIN_FORCE_2FA') === true;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$container = ContainerFactory::getInstance()->getContainer();
|
||||||
|
$moduleConfigurationBridge = $container->get(ModuleConfigurationDaoBridgeInterface::class);
|
||||||
|
/** @var ModuleConfiguration $moduleConfiguration */
|
||||||
|
$moduleConfiguration = $moduleConfigurationBridge->get(Constants::OXID_MODULE_ID);
|
||||||
|
return (bool) $moduleConfiguration->getModuleSetting('D3_TOTP_ADMIN_FORCE_2FA')->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user