enable key login in admin

This commit is contained in:
2022-10-29 00:19:34 +02:00
parent 667c516a00
commit 89a48a00f9
10 changed files with 367 additions and 42 deletions

View File

@ -19,6 +19,7 @@ use D3\Webauthn\Application\Model\d3webauthn;
use D3\Webauthn\Application\Model\WebauthnConf;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Registry;
use ReflectionClass;
use Webauthn\PublicKeyCredentialUserEntity;
class d3_User_Webauthn extends d3_User_Webauthn_parent
@ -78,4 +79,27 @@ class d3_User_Webauthn extends d3_User_Webauthn_parent
throw oxNew(StandardException::class, 'can not create webauthn user entity from not loaded user');
}
public function login($userName, $password, $setSessionCookie = false)
{
if (Registry::getSession()->getVariable(WebauthnConf::WEBAUTHN_SESSION_AUTH)) {
$userName = $userName ?: Registry::getSession()->getVariable(WebauthnConf::WEBAUTHN_SESSION_LOGINUSER);
$config = Registry::getConfig();
$shopId = $config->getShopId();
/** private method is out of scope */
$class = new ReflectionClass($this);
$method = $class->getMethod('loadAuthenticatedUser');
$method->setAccessible(true);
$method->invokeArgs(
$this,
[
Registry::getSession()->getVariable(WebauthnConf::WEBAUTHN_SESSION_LOGINUSER),
$shopId
]
);
}
return parent::login($userName, $password, $setSessionCookie);
}
}