2022-10-24 22:24:40 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This Software is the property of Data Development and is protected
|
|
|
|
* by copyright law - it is NOT Freeware.
|
|
|
|
* Any unauthorized use of this software without a valid license
|
|
|
|
* is a violation of the license agreement and will be prosecuted by
|
|
|
|
* civil and criminal law.
|
|
|
|
* http://www.shopmodule.com
|
|
|
|
*
|
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
|
|
|
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
|
|
|
* @link http://www.oxidmodule.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace D3\Webauthn\Modules\Application\Controller;
|
|
|
|
|
2022-10-29 00:45:11 +02:00
|
|
|
use D3\Webauthn\Application\Model\Webauthn;
|
2022-10-26 22:27:25 +02:00
|
|
|
use D3\Webauthn\Application\Model\WebauthnConf;
|
2022-10-31 23:17:04 +01:00
|
|
|
use Doctrine\DBAL\Driver\Exception;
|
|
|
|
use Doctrine\DBAL\Exception as DoctrineException;
|
2022-10-24 22:24:40 +02:00
|
|
|
use OxidEsales\Eshop\Application\Model\User;
|
|
|
|
use OxidEsales\Eshop\Core\Registry;
|
|
|
|
use OxidEsales\Eshop\Core\Session;
|
2022-10-31 23:17:04 +01:00
|
|
|
use Psr\Container\ContainerExceptionInterface;
|
|
|
|
use Psr\Container\NotFoundExceptionInterface;
|
2022-10-24 22:24:40 +02:00
|
|
|
|
|
|
|
trait d3_webauthn_getUserTrait
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return bool|object|User
|
2022-10-31 23:17:04 +01:00
|
|
|
* @throws Exception
|
|
|
|
* @throws DoctrineException
|
|
|
|
* @throws ContainerExceptionInterface
|
|
|
|
* @throws NotFoundExceptionInterface
|
2022-10-24 22:24:40 +02:00
|
|
|
*/
|
|
|
|
public function getUser()
|
|
|
|
{
|
2022-10-29 00:45:11 +02:00
|
|
|
$user = parent::getUser();
|
2022-10-24 22:24:40 +02:00
|
|
|
|
2022-10-29 00:45:11 +02:00
|
|
|
if ($user && $user->getId()) {
|
2022-10-24 22:24:40 +02:00
|
|
|
$webauthn = $this->d3GetWebauthnpObject();
|
|
|
|
|
2022-10-29 00:45:11 +02:00
|
|
|
if ($webauthn->isActive($user->getId())
|
2022-10-31 23:17:04 +01:00
|
|
|
&& !$this->d3GetSessionObject()->getVariable(WebauthnConf::WEBAUTHN_SESSION_AUTH)
|
2022-10-24 22:24:40 +02:00
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-29 00:45:11 +02:00
|
|
|
return $user;
|
2022-10-24 22:24:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-10-29 00:45:11 +02:00
|
|
|
* @return Webauthn
|
2022-10-24 22:24:40 +02:00
|
|
|
*/
|
2022-10-31 23:17:04 +01:00
|
|
|
public function d3GetWebauthnObject(): Webauthn
|
2022-10-24 22:24:40 +02:00
|
|
|
{
|
2022-10-29 00:45:11 +02:00
|
|
|
return oxNew(Webauthn::class);
|
2022-10-24 22:24:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Session
|
|
|
|
*/
|
2022-10-31 23:17:04 +01:00
|
|
|
public function d3GetSessionObject(): Session
|
2022-10-24 22:24:40 +02:00
|
|
|
{
|
|
|
|
return Registry::getSession();
|
|
|
|
}
|
|
|
|
}
|