add global disable variable
This commit is contained in:
parent
19b3dc7881
commit
12294725bc
@ -78,7 +78,14 @@ class d3totp extends BaseModel
|
|||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isActive()
|
||||||
|
{
|
||||||
|
return false == Registry::getConfig()->getConfigParam('blDisableTotpGlobally')
|
||||||
|
&& $this->UserUseTotp();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $userId
|
* @param $userId
|
||||||
|
@ -1,116 +1,116 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Software is the property of Data Development and is protected
|
* This Software is the property of Data Development and is protected
|
||||||
* by copyright law - it is NOT Freeware.
|
* by copyright law - it is NOT Freeware.
|
||||||
* Any unauthorized use of this software without a valid license
|
* Any unauthorized use of this software without a valid license
|
||||||
* is a violation of the license agreement and will be prosecuted by
|
* is a violation of the license agreement and will be prosecuted by
|
||||||
* civil and criminal law.
|
* civil and criminal law.
|
||||||
* http://www.shopmodule.com
|
* http://www.shopmodule.com
|
||||||
*
|
*
|
||||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace D3\Totp\Modules\Application\Controller\Admin;
|
namespace D3\Totp\Modules\Application\Controller\Admin;
|
||||||
|
|
||||||
use D3\Totp\Application\Model\d3totp;
|
use D3\Totp\Application\Model\d3totp;
|
||||||
use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException;
|
use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException;
|
||||||
use Doctrine\DBAL\DBALException;
|
use Doctrine\DBAL\DBALException;
|
||||||
use OxidEsales\Eshop\Application\Model\User;
|
use OxidEsales\Eshop\Application\Model\User;
|
||||||
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
||||||
use OxidEsales\Eshop\Core\Registry;
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
|
|
||||||
class d3_totp_LoginController extends d3_totp_LoginController_parent
|
class d3_totp_LoginController extends d3_totp_LoginController_parent
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
* @throws DBALException
|
* @throws DBALException
|
||||||
* @throws DatabaseConnectionException
|
* @throws DatabaseConnectionException
|
||||||
*/
|
*/
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
$auth = Registry::getSession()->getVariable("auth");
|
$auth = Registry::getSession()->getVariable("auth");
|
||||||
|
|
||||||
$return = parent::render();
|
$return = parent::render();
|
||||||
|
|
||||||
$totp = oxNew(d3totp::class);
|
$totp = oxNew(d3totp::class);
|
||||||
$totp->loadByUserId($auth);
|
$totp->loadByUserId($auth);
|
||||||
|
|
||||||
if ($auth
|
if ($auth
|
||||||
&& $totp->UserUseTotp()
|
&& $totp->isActive()
|
||||||
&& false == Registry::getSession()->getVariable(d3totp::TOTP_SESSION_VARNAME)
|
&& false == Registry::getSession()->getVariable(d3totp::TOTP_SESSION_VARNAME)
|
||||||
&& Registry::getSession()->hasVariable('pwdTransmit')
|
&& Registry::getSession()->hasVariable('pwdTransmit')
|
||||||
) {
|
) {
|
||||||
// set auth as secured parameter;
|
// set auth as secured parameter;
|
||||||
Registry::getSession()->setVariable("auth", $auth);
|
Registry::getSession()->setVariable("auth", $auth);
|
||||||
$this->addTplParam('request_totp', true);
|
$this->addTplParam('request_totp', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed|string
|
* @return mixed|string
|
||||||
* @throws DBALException
|
* @throws DBALException
|
||||||
* @throws DatabaseConnectionException
|
* @throws DatabaseConnectionException
|
||||||
*/
|
*/
|
||||||
public function checklogin()
|
public function checklogin()
|
||||||
{
|
{
|
||||||
$sTotp = Registry::getRequest()->getRequestEscapedParameter('d3totp', true);
|
$sTotp = Registry::getRequest()->getRequestEscapedParameter('d3totp', true);
|
||||||
|
|
||||||
$totp = oxNew(d3totp::class);
|
$totp = oxNew(d3totp::class);
|
||||||
$totp->loadByUserId(Registry::getSession()->getVariable("auth"));
|
$totp->loadByUserId(Registry::getSession()->getVariable("auth"));
|
||||||
|
|
||||||
if (Registry::getRequest()->getRequestParameter('pwd')) {
|
if (Registry::getRequest()->getRequestParameter('pwd')) {
|
||||||
Registry::getSession()->setVariable('pwdTransmit', Registry::getRequest()->getRequestParameter('pwd'));
|
Registry::getSession()->setVariable('pwdTransmit', Registry::getRequest()->getRequestParameter('pwd'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$return = 'login';
|
$return = 'login';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($this->isNoTotpOrNoLogin($totp)) {
|
if ($this->isNoTotpOrNoLogin($totp)) {
|
||||||
$return = parent::checklogin();
|
$return = parent::checklogin();
|
||||||
} elseif ($this->hasValidTotp($sTotp, $totp)) {
|
} elseif ($this->hasValidTotp($sTotp, $totp)) {
|
||||||
Registry::getSession()->setVariable(d3totp::TOTP_SESSION_VARNAME, $sTotp);
|
Registry::getSession()->setVariable(d3totp::TOTP_SESSION_VARNAME, $sTotp);
|
||||||
Registry::getSession()->deleteVariable('pwdTransmit');
|
Registry::getSession()->deleteVariable('pwdTransmit');
|
||||||
$return = "admin_start";
|
$return = "admin_start";
|
||||||
}
|
}
|
||||||
} catch (d3totp_wrongOtpException $oEx) {
|
} catch (d3totp_wrongOtpException $oEx) {
|
||||||
Registry::getUtilsView()->addErrorToDisplay($oEx);
|
Registry::getUtilsView()->addErrorToDisplay($oEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param d3totp $totp
|
* @param d3totp $totp
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isNoTotpOrNoLogin($totp)
|
public function isNoTotpOrNoLogin($totp)
|
||||||
{
|
{
|
||||||
return false == Registry::getSession()->getVariable("auth")
|
return false == Registry::getSession()->getVariable("auth")
|
||||||
|| false == $totp->UserUseTotp();
|
|| false == $totp->isActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $sTotp
|
* @param string $sTotp
|
||||||
* @param d3totp $totp
|
* @param d3totp $totp
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws d3totp_wrongOtpException
|
* @throws d3totp_wrongOtpException
|
||||||
*/
|
*/
|
||||||
public function hasValidTotp($sTotp, $totp)
|
public function hasValidTotp($sTotp, $totp)
|
||||||
{
|
{
|
||||||
return Registry::getSession()->getVariable(d3totp::TOTP_SESSION_VARNAME) ||
|
return Registry::getSession()->getVariable(d3totp::TOTP_SESSION_VARNAME) ||
|
||||||
(
|
(
|
||||||
$sTotp && $totp->verify($sTotp)
|
$sTotp && $totp->verify($sTotp)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function d3CancelLogin()
|
public function d3CancelLogin()
|
||||||
{
|
{
|
||||||
$oUser = oxNew(User::class);
|
$oUser = oxNew(User::class);
|
||||||
$oUser->logout();
|
$oUser->logout();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -37,7 +37,7 @@ class d3_totp_utils extends d3_totp_utils_parent
|
|||||||
$totp = oxNew(d3totp::class);
|
$totp = oxNew(d3totp::class);
|
||||||
$totp->loadByUserId($userID);
|
$totp->loadByUserId($userID);
|
||||||
|
|
||||||
if ($blAuth && $totp->UserUseTotp() && false === $totpAuth) {
|
if ($blAuth && $totp->isActive() && false === $totpAuth) {
|
||||||
Registry::getUtils()->redirect('index.php?cl=login', true, 302);
|
Registry::getUtils()->redirect('index.php?cl=login', true, 302);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user