improve code
This commit is contained in:
@ -107,7 +107,7 @@ class d3user_webauthn extends AdminDetailsController
|
||||
$publicKeyCredentialCreationOptions
|
||||
);
|
||||
} catch (WebauthnException $e) {
|
||||
// ToDo: log exc message
|
||||
// ToDo: log exc message and show message
|
||||
}
|
||||
|
||||
$this->addTplParam('isAdmin', isAdmin());
|
||||
|
@ -22,16 +22,17 @@ use D3\Webauthn\Application\Model\WebauthnErrors;
|
||||
use D3\Webauthn\Application\Model\WebauthnException;
|
||||
use D3\Webauthn\Modules\Application\Component\d3_webauthn_UserComponent;
|
||||
use D3\Webauthn\Modules\Application\Model\d3_User_Webauthn;
|
||||
use Exception;
|
||||
use Doctrine\DBAL\Driver\Exception as DoctrineDriverException;
|
||||
use Doctrine\DBAL\Exception as DoctrineException;
|
||||
use OxidEsales\Eshop\Application\Controller\Admin\AdminController;
|
||||
use OxidEsales\Eshop\Application\Controller\Admin\LoginController;
|
||||
use OxidEsales\Eshop\Application\Controller\FrontendController;
|
||||
use OxidEsales\Eshop\Application\Model\User;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\Eshop\Core\Utils;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class d3webauthnadminlogin extends AdminController
|
||||
{
|
||||
@ -44,8 +45,10 @@ class d3webauthnadminlogin extends AdminController
|
||||
|
||||
/**
|
||||
* @return null
|
||||
* @throws DatabaseConnectionException
|
||||
* @throws DatabaseErrorException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws DoctrineDriverException
|
||||
* @throws DoctrineException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
@ -62,11 +65,16 @@ class d3webauthnadminlogin extends AdminController
|
||||
|
||||
$this->generateCredentialRequest();
|
||||
|
||||
//$this->addTplParam('navFormParams', Registry::getSession()->getVariable(WebauthnConf::WEBAUTHN_SESSION_NAVFORMPARAMS));
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws DoctrineDriverException
|
||||
* @throws DoctrineException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function generateCredentialRequest()
|
||||
{
|
||||
try {
|
||||
@ -78,7 +86,11 @@ class d3webauthnadminlogin extends AdminController
|
||||
$this->addTplParam('webauthn_publickey_login', $publicKeyCredentialRequestOptions);
|
||||
$this->addTplParam('isAdmin', isAdmin());
|
||||
} catch (WebauthnException $e) {
|
||||
// ToDo write exc message to display and log
|
||||
Registry::getSession()->setVariable(WebauthnConf::GLOBAL_SWITCH, true);
|
||||
$exception = oxNew(WebauthnException::class, Registry::getLang()->translateString('D3_WEBAUTHN_ERR_LOGINPROHIBITED'));
|
||||
Registry::getUtilsView()->addErrorToDisplay($exception);
|
||||
Registry::getLogger()->error('webauthn request options: '.$e->getMessage());
|
||||
$this->getUtils()->redirect('index.php?cl=login');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ use D3\Webauthn\Application\Model\WebauthnErrors;
|
||||
use D3\Webauthn\Application\Model\WebauthnException;
|
||||
use D3\Webauthn\Modules\Application\Component\d3_webauthn_UserComponent;
|
||||
use D3\Webauthn\Modules\Application\Model\d3_User_Webauthn;
|
||||
use Doctrine\DBAL\Driver\Exception as DoctrineDriverException;
|
||||
use Doctrine\DBAL\Exception as DoctrineException;
|
||||
use OxidEsales\Eshop\Application\Controller\FrontendController;
|
||||
use OxidEsales\Eshop\Application\Model\User;
|
||||
@ -39,8 +40,12 @@ class d3webauthnlogin extends FrontendController
|
||||
|
||||
/**
|
||||
* @return null
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws DatabaseConnectionException
|
||||
* @throws DatabaseErrorException
|
||||
* @throws DoctrineDriverException
|
||||
* @throws DoctrineException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
@ -64,7 +69,7 @@ class d3webauthnlogin extends FrontendController
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws \Doctrine\DBAL\Driver\Exception
|
||||
* @throws DoctrineDriverException
|
||||
* @throws DoctrineException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
@ -78,7 +83,11 @@ class d3webauthnlogin extends FrontendController
|
||||
$publicKeyCredentialRequestOptions = $webauthn->getRequestOptions($userId);
|
||||
$this->addTplParam('webauthn_publickey_login', $publicKeyCredentialRequestOptions);
|
||||
} catch (WebauthnException $e) {
|
||||
// ToDo: write exc msg to display and log
|
||||
Registry::getSession()->setVariable(WebauthnConf::GLOBAL_SWITCH, true);
|
||||
$exception = oxNew(WebauthnException::class, Registry::getLang()->translateString('D3_WEBAUTHN_ERR_LOGINPROHIBITED'));
|
||||
Registry::getUtilsView()->addErrorToDisplay($exception);
|
||||
Registry::getLogger()->error('webauthn request options: '.$e->getMessage());
|
||||
$this->getUtils()->redirect('index.php?cl=start');
|
||||
}
|
||||
|
||||
$this->addTplParam('isAdmin', isAdmin());
|
||||
|
@ -186,7 +186,8 @@ class Webauthn
|
||||
*/
|
||||
public function isActive($userId): bool
|
||||
{
|
||||
return false == Registry::getConfig()->getConfigParam('blDisableWebauthnGlobally')
|
||||
return !Registry::getConfig()->getConfigParam(WebauthnConf::GLOBAL_SWITCH)
|
||||
&& !Registry::getSession()->getVariable(WebauthnConf::GLOBAL_SWITCH)
|
||||
&& $this->UserUseWebauthn($userId);
|
||||
}
|
||||
|
||||
|
@ -23,4 +23,6 @@ class WebauthnConf
|
||||
public const WEBAUTHN_SESSION_LOGINUSER = 'd3webauthnLoginUser'; // username entered in login form
|
||||
public const WEBAUTHN_SESSION_CURRENTCLASS = 'd3webauthnCurrentClass'; // no usage
|
||||
public const WEBAUTHN_SESSION_NAVFORMPARAMS = 'd3webauthnNavFormParams'; // no usage
|
||||
|
||||
public const GLOBAL_SWITCH = 'blDisableWebauthnGlobally';
|
||||
}
|
@ -28,4 +28,6 @@ $aLang = array(
|
||||
'D3_WEBAUTHN_ACCOUNT_TYPE1' => 'nur Auth-Stick',
|
||||
'D3_WEBAUTHN_ACCOUNT_TYPE2' => 'nur Auth-Stick, Passwort als Alternative',
|
||||
'D3_WEBAUTHN_ACCOUNT_TYPE3' => 'Auth-Stick und Passwort in Kombination',
|
||||
|
||||
'D3_WEBAUTHN_ERR_LOGINPROHIBITED' => 'Die Anmeldung mit Sicherheitsschlüssel ist aus technischen Gründen derzeit leider nicht möglich. Bitte verwenden Sie statt dessen Ihr Passwort.',
|
||||
);
|
||||
|
@ -46,4 +46,6 @@ $aLang = [
|
||||
'D3_WEBAUTHN_ERR_NOTSUPPORTED' => 'Die Aktion wird nicht unterstützt.',
|
||||
'D3_WEBAUTHN_ERR_UNKNOWN' => 'Die Aktion wurde wegen eines unbekannten Fehlers abgebrochen.',
|
||||
'D3_WEBAUTHN_ERR_NOPUBKEYSUPPORT' => 'Ihr Browser unterstützt die Verwendung von Hardwareschlüsseln leider nicht.',
|
||||
|
||||
'D3_WEBAUTHN_ERR_LOGINPROHIBITED' => 'Die Anmeldung mit Sicherheitsschlüssel ist aus technischen Gründen derzeit leider nicht möglich. Bitte verwenden Sie statt dessen Ihr Passwort.',
|
||||
];
|
||||
|
@ -47,4 +47,5 @@ $aLang = [
|
||||
'D3_WEBAUTHN_ERR_UNKNOWN' => 'The action was cancelled due to an unknown error.',
|
||||
'D3_WEBAUTHN_ERR_NOPUBKEYSUPPORT' => 'Unfortunately, your browser does not support the use of hardware keys.',
|
||||
|
||||
'D3_WEBAUTHN_ERR_LOGINPROHIBITED' => 'Unfortunately, logging in with a security key is currently not possible for technical reasons. Please use your password instead.',
|
||||
];
|
||||
|
Reference in New Issue
Block a user