cleanup code

This commit is contained in:
Daniel Seifert 2022-10-29 00:45:11 +02:00
parent 89a48a00f9
commit a23ec6ad32
Signed by: DanielS
GPG Key ID: 6A513E13AEE66170
5 changed files with 11 additions and 102 deletions

View File

@ -17,7 +17,6 @@ namespace D3\Webauthn\Application\Controller\Admin;
use D3\Webauthn\Application\Model\Credential\PublicKeyCredential;
use D3\Webauthn\Application\Model\Credential\PublicKeyCredentialList;
use D3\Webauthn\Application\Model\d3webauthn;
use D3\Webauthn\Application\Model\Webauthn;
use D3\Webauthn\Application\Model\WebauthnErrors;
use D3\Webauthn\Modules\Application\Model\d3_User_Webauthn;
@ -132,14 +131,6 @@ class d3user_webauthn extends AdminDetailsController
return oxNew(User::class);
}
/**
* @return d3webauthn
*/
public function getWebauthnObject()
{
return oxNew(d3webauthn::class);
}
public function deleteKey()
{
/** @var PublicKeyCredential $credential */

View File

@ -103,8 +103,6 @@ class d3webauthnadminlogin extends AdminController
/** @var d3_webauthn_UserComponent $userCmp */
$loginController = oxNew(LoginController::class);
return $loginController->checklogin();
//Registry::getSession()->setVariable(WebauthnConf::WEBAUTHN_SESSION_AUTH, true);
}
} catch (Exception $e) {

View File

@ -15,12 +15,8 @@
namespace D3\Webauthn\Modules\Application\Controller\Admin;
use D3\Webauthn\Application\Model\d3webauthn;
use D3\Webauthn\Application\Model\Webauthn;
use D3\Webauthn\Application\Model\WebauthnConf;
use D3\Webauthn\Application\Model\Exceptions\d3WebauthnExceptionAbstract;
use D3\Webauthn\Application\Model\Exceptions\d3webauthnMissingPublicKeyCredentialRequestOptions;
use D3\Webauthn\Application\Model\Exceptions\d3webauthnWrongAuthException;
use Doctrine\DBAL\Driver\Exception as DoctrineException;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Query\QueryBuilder;
@ -37,31 +33,7 @@ use Psr\Container\NotFoundExceptionInterface;
class d3_LoginController_Webauthn extends d3_LoginController_Webauthn_parent
{
/**
* @return string
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
*/
public function render()
{
$auth = $this->d3GetSession()->getVariable("auth");
$return = parent::render();
if ($auth) {
$webauthn = $this->d3GetWebauthnObject();
$publicKeyCredentialRequestOptions = $webauthn->getCredentialRequestOptions($auth);
$this->addTplParam(
'webauthn_publickey_login',
$publicKeyCredentialRequestOptions
);
$this->addTplParam('request_webauthn', true);
}
return $return;
}
/**
* @return Webauthn
@ -71,22 +43,6 @@ class d3_LoginController_Webauthn extends d3_LoginController_Webauthn_parent
return oxNew(Webauthn::class);
}
/**
* @return UtilsView
*/
public function d3GetUtilsView()
{
return Registry::getUtilsView();
}
/**
* @return Session
*/
public function d3GetSession()
{
return Registry::getSession();
}
/**
* @return mixed|string
* @throws DatabaseConnectionException
@ -163,31 +119,6 @@ class d3_LoginController_Webauthn extends d3_LoginController_Webauthn_parent
return $qb->execute()->fetchOne();
}
/**
* @param d3webauthn $webauthn
* @return bool
*/
public function d3IsNoWebauthnOrNoLogin($webauthn)
{
return false == $this->d3GetSession()->getVariable("auth")
|| false == $webauthn->isActive();
}
/**
* @param string $sWebauth
* @param d3webauthn $webauthn
* @return bool
* @throws d3webauthnMissingPublicKeyCredentialRequestOptions
* @throws d3webauthnWrongAuthException
*/
public function hasValidWebauthn($sWebauth, $webauthn)
{
return Registry::getSession()->getVariable(WebauthnConf::WEBAUTHN_SESSION_AUTH) ||
(
$sWebauth && $webauthn->verify($sWebauth)
);
}
public function d3WebauthnCancelLogin()
{
$oUser = $this->d3GetUserObject();

View File

@ -15,11 +15,9 @@
namespace D3\Webauthn\Modules\Application\Controller;
use D3\Webauthn\Application\Model\d3webauthn;
use D3\Webauthn\Application\Model\Webauthn;
use D3\Webauthn\Application\Model\WebauthnConf;
use Doctrine\DBAL\DBALException;
use OxidEsales\Eshop\Application\Model\User;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\Session;
@ -27,33 +25,30 @@ trait d3_webauthn_getUserTrait
{
/**
* @return bool|object|User
* @throws DatabaseConnectionException
* @throws DBALException
*/
public function getUser()
{
$oUser = parent::getUser();
$user = parent::getUser();
if ($oUser && $oUser->getId()) {
if ($user && $user->getId()) {
$webauthn = $this->d3GetWebauthnpObject();
$webauthn->loadByUserId($oUser->getId());
if ($webauthn->isActive()
if ($webauthn->isActive($user->getId())
&& false == $this->d3GetSessionObject()->getVariable(WebauthnConf::WEBAUTHN_SESSION_AUTH)
) {
return false;
}
}
return $oUser;
return $user;
}
/**
* @return d3webauthn
* @return Webauthn
*/
public function d3GetWebauthnpObject()
public function d3GetWebauthnObject()
{
return oxNew(d3webauthn::class);
return oxNew(Webauthn::class);
}
/**

View File

@ -15,7 +15,6 @@
namespace D3\Webauthn\Modules\Application\Model;
use D3\Webauthn\Application\Model\d3webauthn;
use D3\Webauthn\Application\Model\WebauthnConf;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Registry;
@ -31,6 +30,7 @@ class d3_User_Webauthn extends d3_User_Webauthn_parent
Registry::getSession()->deleteVariable(WebauthnConf::WEBAUTHN_SESSION_AUTH);
Registry::getSession()->deleteVariable(WebauthnConf::WEBAUTHN_LOGIN_OBJECT);
Registry::getSession()->deleteVariable(WebauthnConf::WEBAUTHN_SESSION_CURRENTUSER);
Registry::getSession()->deleteVariable(WebauthnConf::WEBAUTHN_SESSION_LOGINUSER);
Registry::getSession()->deleteVariable(WebauthnConf::WEBAUTHN_SESSION_CURRENTCLASS);
Registry::getSession()->deleteVariable(WebauthnConf::WEBAUTHN_SESSION_NAVFORMPARAMS);
@ -44,6 +44,7 @@ class d3_User_Webauthn extends d3_User_Webauthn_parent
$currentUser = Registry::getSession()->getVariable(WebauthnConf::WEBAUTHN_SESSION_CURRENTUSER);
$currentClass = Registry::getSession()->getVariable(WebauthnConf::WEBAUTHN_SESSION_CURRENTCLASS);
$navFormParams = Registry::getSession()->getVariable(WebauthnConf::WEBAUTHN_SESSION_NAVFORMPARAMS);
$loginUser = Registry::getSession()->getVariable(WebauthnConf::WEBAUTHN_SESSION_LOGINUSER);
$return = $this->logout();
@ -52,18 +53,11 @@ class d3_User_Webauthn extends d3_User_Webauthn_parent
Registry::getSession()->setVariable(WebauthnConf::WEBAUTHN_SESSION_CURRENTUSER, $currentUser);
Registry::getSession()->setVariable(WebauthnConf::WEBAUTHN_SESSION_CURRENTCLASS, $currentClass);
Registry::getSession()->setVariable(WebauthnConf::WEBAUTHN_SESSION_NAVFORMPARAMS, $navFormParams);
Registry::getSession()->setVariable(WebauthnConf::WEBAUTHN_SESSION_LOGINUSER, $loginUser);
return $return;
}
/**
* @return d3webauthn
*/
public function d3getWebauthn()
{
return oxNew(d3webauthn::class);
}
/**
* @return PublicKeyCredentialUserEntity
*/