* @link https://www.oxidmodule.com */ declare(strict_types=1); namespace D3\Webauthn\Application\Controller\Traits; use D3\TestingTools\Production\IsMockable; use D3\Webauthn\Application\Model\Webauthn; use D3\Webauthn\Application\Model\WebauthnConf; use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Exception as DoctrineException; use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Core\Session; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; trait checkoutGetUserTrait { use IsMockable; /** * @return false|User * @throws ContainerExceptionInterface * @throws DoctrineException * @throws Exception * @throws NotFoundExceptionInterface */ public function getUser() { /** @var User|null $user */ $user = $this->d3CallMockableFunction([$this->parentClass, 'getUser']); if ($user && $user->isLoaded() && $user->getId()) { $webauthn = $this->d3GetMockableOxNewObject(Webauthn::class); if ($webauthn->isActive($user->getId()) && !$this->d3GetMockableRegistryObject(Session::class) ->getVariable(WebauthnConf::WEBAUTHN_SESSION_AUTH) ) { return false; } } return $user; } }