extend login form

This commit is contained in:
Daniel Seifert 2018-10-17 16:21:49 +02:00
parent cecfa24161
commit d8cd285342
3 changed files with 51 additions and 5 deletions

View File

@ -2,6 +2,7 @@
"name": "d3/totp",
"description": "Two-factor authentication for OXID eSales shop",
"type": "oxideshop-module",
"version": "0.1",
"keywords": [
"oxid",
"modules",

View File

@ -15,11 +15,55 @@
namespace D3\Totp\Modules\Application\Controller\Admin;
use D3\Totp\Application\Model\d3totp;
use Doctrine\DBAL\DBALException;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Registry;
class d3_totp_LoginController extends d3_totp_LoginController_parent
{
/**
* @return string
* @throws DBALException
* @throws DatabaseConnectionException
*/
public function render()
{
// check for username / password or totp auth
return parent::render();
$auth = Registry::getSession()->getVariable("auth");
$return = parent::render();
if ($auth
&& oxNew(d3totp::class)->UserUseTotp($auth)
&& false == Registry::getSession()->getVariable("totp_auth")
) {
// set auth as secured parameter;
$return = 'd3login_totp.tpl';
}
return $return;
}
/**
* @return mixed|string
* @throws DBALException
* @throws DatabaseConnectionException
*/
public function checklogin()
{
$return = parent::checklogin();
if ($return == "admin_start") {
if ((bool) $this->getSession()->checkSessionChallenge()
&& count(\OxidEsales\Eshop\Core\Registry::getUtilsServer()->getOxCookie())
&& Registry::getSession()->getVariable("auth")
&& oxNew(d3totp::class)->UserUseTotp(Registry::getSession()->getVariable("auth"))
&& false == Registry::getSession()->getVariable("totp_auth")
) {
$return = "login";
}
}
return $return;
}
}

View File

@ -32,12 +32,13 @@ class d3_totp_utils extends d3_totp_utils_parent
$blAuth = parent::checkAccessRights();
$userID = Registry::getSession()->getVariable("auth");
$totpAuth = (bool) Registry::getSession()->getVariable("totp_auth");
/** @var d3totp $totp */
$totp = oxNew(d3totp::class);
// und kein auth
if ($blAuth && $totp->UserUseTotp($userID)) {
echo __CLASS__." - ".__FUNCTION__." - ".__LINE__."<br>";
if (1 == 0 && $blAuth && $totp->UserUseTotp($userID) && false === $totpAuth) {
Registry::getUtils()->redirect('index.php?cl=login', true, 302);
exit;
}
return $blAuth;