* @link https://www.oxidmodule.com */ declare(strict_types=1); namespace D3\Totp\Modules\Application\Controller; use D3\TestingTools\Production\IsMockable; use D3\Totp\Application\Model\d3totp; use D3\Totp\Application\Model\d3totp_conf; use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Session; trait d3_totp_getUserTrait { use IsMockable; /** * @return bool|object|User * @throws DatabaseConnectionException */ public function getUser() { /** @var User|null $user */ $user = $this->d3CallMockableFunction([$this->parentClass, 'getUser']); if ($user && $user->isLoaded() && $user->getId()) { $totp = $this->d3GetTotpObject(); $totp->loadByUserId($user->getId()); if ($totp->isActive() && !$this->d3TotpGetSessionObject()->getVariable( isAdmin() ? d3totp_conf::SESSION_ADMIN_AUTH : d3totp_conf::SESSION_AUTH ) ) { return false; } } return $user; } /** * @return d3totp */ public function d3GetTotpObject() { return oxNew(d3totp::class); } /** * @return Session */ public function d3TotpGetSessionObject() { return Registry::getSession(); } }