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-24 22:24:40 +02:00
|
|
|
use OxidEsales\Eshop\Application\Model\User;
|
|
|
|
use OxidEsales\Eshop\Core\Registry;
|
|
|
|
use OxidEsales\Eshop\Core\Session;
|
|
|
|
|
|
|
|
trait d3_webauthn_getUserTrait
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return bool|object|User
|
|
|
|
*/
|
|
|
|
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-26 22:27:25 +02:00
|
|
|
&& false == $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-29 00:45:11 +02:00
|
|
|
public function d3GetWebauthnObject()
|
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
|
|
|
|
*/
|
|
|
|
public function d3GetSessionObject()
|
|
|
|
{
|
|
|
|
return Registry::getSession();
|
|
|
|
}
|
|
|
|
}
|