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
|
|
|
*/
|
|
|
|
|
|
|
|
namespace D3\Totp\Modules\Application\Controller;
|
|
|
|
|
|
|
|
use D3\Totp\Application\Model\d3totp;
|
|
|
|
use Doctrine\DBAL\DBALException;
|
|
|
|
use OxidEsales\Eshop\Application\Model\User;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
|
|
|
use OxidEsales\Eshop\Core\Registry;
|
2019-08-08 23:50:09 +02:00
|
|
|
use OxidEsales\Eshop\Core\Session;
|
2019-07-31 22:43:34 +02:00
|
|
|
|
|
|
|
trait d3_totp_getUserTrait
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return bool|object|User
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DBALException
|
|
|
|
*/
|
|
|
|
public function getUser()
|
|
|
|
{
|
|
|
|
$oUser = parent::getUser();
|
|
|
|
|
|
|
|
if ($oUser && $oUser->getId()) {
|
2019-08-08 23:50:09 +02:00
|
|
|
$totp = $this->d3GetTotpObject();
|
2019-07-31 22:43:34 +02:00
|
|
|
$totp->loadByUserId($oUser->getId());
|
|
|
|
|
|
|
|
if ($totp->isActive()
|
2019-08-08 23:50:09 +02:00
|
|
|
&& false == $this->d3GetSessionObject()->getVariable(d3totp::TOTP_SESSION_VARNAME)
|
2019-07-31 22:43:34 +02:00
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $oUser;
|
|
|
|
}
|
2019-08-08 23:50:09 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return d3totp
|
|
|
|
*/
|
|
|
|
public function d3GetTotpObject()
|
|
|
|
{
|
|
|
|
return oxNew(d3totp::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Session
|
|
|
|
*/
|
|
|
|
public function d3GetSessionObject()
|
|
|
|
{
|
|
|
|
return Registry::getSession();
|
|
|
|
}
|
2019-07-31 22:43:34 +02:00
|
|
|
}
|