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\Modules\Application\Controller;
|
|
|
|
|
|
|
|
use D3\Totp\Application\Model\d3totp;
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
public function getUser()
|
|
|
|
{
|
|
|
|
$oUser = parent::getUser();
|
|
|
|
|
2022-10-01 14:44:36 +02:00
|
|
|
if ($oUser instanceof User && $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()
|
2022-11-09 12:03:16 +01:00
|
|
|
&& !$this->d3TotpGetSessionObject()->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
|
|
|
|
*/
|
2022-11-09 12:03:16 +01:00
|
|
|
public function d3TotpGetSessionObject()
|
2019-08-08 23:50:09 +02:00
|
|
|
{
|
|
|
|
return Registry::getSession();
|
|
|
|
}
|
2022-09-30 21:06:30 +02:00
|
|
|
}
|