From ed3eee4e67ca999a8a456dfb8c5b08ba6b2d64a4 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Wed, 17 Oct 2018 23:48:20 +0200 Subject: [PATCH] add setup, admin panel, tpl block --- .../Controller/Admin/d3user_totp.php | 23 ++++++++ .../blocks/d3totp_login_admin_login_form.tpl | 17 ++++++ .../views/admin/de/d3totp_lang.php | 27 ++++++++++ .../views/admin/en/d3totp_lang.php | 27 ++++++++++ .../views/admin/tpl/d3user_totp.tpl | 6 +++ src/Setup/Events.php | 48 +++++++++++++++++ src/Setup/Installation.php | 23 ++++++++ src/menu.xml | 10 ++++ src/metadata.php | 53 +++++++++++-------- 9 files changed, 212 insertions(+), 22 deletions(-) create mode 100644 src/Application/Controller/Admin/d3user_totp.php create mode 100644 src/Application/views/admin/blocks/d3totp_login_admin_login_form.tpl create mode 100644 src/Application/views/admin/de/d3totp_lang.php create mode 100644 src/Application/views/admin/en/d3totp_lang.php create mode 100644 src/Application/views/admin/tpl/d3user_totp.tpl create mode 100644 src/Setup/Events.php create mode 100644 src/Setup/Installation.php create mode 100644 src/menu.xml diff --git a/src/Application/Controller/Admin/d3user_totp.php b/src/Application/Controller/Admin/d3user_totp.php new file mode 100644 index 0000000..4112e43 --- /dev/null +++ b/src/Application/Controller/Admin/d3user_totp.php @@ -0,0 +1,23 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\Totp\Application\Controller\Admin; + +use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController; + +class d3user_totp extends AdminDetailsController +{ + protected $_sThisTemplate = 'd3user_totp.tpl'; +} \ No newline at end of file diff --git a/src/Application/views/admin/blocks/d3totp_login_admin_login_form.tpl b/src/Application/views/admin/blocks/d3totp_login_admin_login_form.tpl new file mode 100644 index 0000000..498ceaf --- /dev/null +++ b/src/Application/views/admin/blocks/d3totp_login_admin_login_form.tpl @@ -0,0 +1,17 @@ +[{if $request_totp}] + [{$oViewConf->getHiddenSid()}] + + + + + [{if $Errors.default|@count}] + [{include file="inc_error.tpl" Errorlist=$Errors.default}] + [{/if}] + + +
+ + [{oxmultilang ident="TOTP_INPUT_HELP"}] +[{else}] + [{$smarty.block.parent}] +[{/if}] \ No newline at end of file diff --git a/src/Application/views/admin/de/d3totp_lang.php b/src/Application/views/admin/de/d3totp_lang.php new file mode 100644 index 0000000..478d60d --- /dev/null +++ b/src/Application/views/admin/de/d3totp_lang.php @@ -0,0 +1,27 @@ + + * @link http://www.oxidmodule.com + */ + +$sLangName = "Deutsch"; + +$aLang = [ + 'charset' => 'UTF-8', + + 'TOTP_INPUT' => 'Authentisierungscode', + 'TOTP_INPUT_HELP' => 'Den Authentisierungscode erhalten Sie von der Zweifaktorauthentisierung-App auf Ihrem Gerät.', + + 'd3mxuser_totp' => '2-Faktor-Authentisierung', +]; diff --git a/src/Application/views/admin/en/d3totp_lang.php b/src/Application/views/admin/en/d3totp_lang.php new file mode 100644 index 0000000..fcd117f --- /dev/null +++ b/src/Application/views/admin/en/d3totp_lang.php @@ -0,0 +1,27 @@ + + * @link http://www.oxidmodule.com + */ + +$sLangName = "English"; + +$aLang = [ + 'charset' => 'UTF-8', + + 'TOTP_INPUT' => 'authentication code', + 'TOTP_INPUT_HELP' => 'The authentication code is available from the Two-Factor Authentication app on your device.', + + 'd3mxuser_totp' => 'Two-factor authentication', +]; diff --git a/src/Application/views/admin/tpl/d3user_totp.tpl b/src/Application/views/admin/tpl/d3user_totp.tpl new file mode 100644 index 0000000..5fa15e7 --- /dev/null +++ b/src/Application/views/admin/tpl/d3user_totp.tpl @@ -0,0 +1,6 @@ +[{include file="headitem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign}] + +foo + +[{include file="bottomnaviitem.tpl"}] +[{include file="bottomitem.tpl"}] \ No newline at end of file diff --git a/src/Setup/Events.php b/src/Setup/Events.php new file mode 100644 index 0000000..9f974ee --- /dev/null +++ b/src/Setup/Events.php @@ -0,0 +1,48 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\Totp\Setup; + +use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException; +use D3\ModCfg\Application\Model\Install\d3install; +use Doctrine\DBAL\DBALException; +use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; +use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; +use OxidEsales\Eshop\Core\Exception\StandardException; +use OxidEsales\Eshop\Core\Exception\SystemComponentException; + +class Events +{ + /** + * @throws d3ShopCompatibilityAdapterException + * @throws DBALException + * @throws DatabaseConnectionException + * @throws DatabaseErrorException + * @throws StandardException + * @throws SystemComponentException + */ + public static function onActivate() + { + if (class_exists(d3install::class)) { + d3install::checkUpdateStart(); + } + } + + public static function onDeactivate() + { + } +} \ No newline at end of file diff --git a/src/Setup/Installation.php b/src/Setup/Installation.php new file mode 100644 index 0000000..d7ad188 --- /dev/null +++ b/src/Setup/Installation.php @@ -0,0 +1,23 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\Totp\Setup; + +use D3\ModCfg\Application\Model\Install\d3install_updatebase; + +class Installation extends d3install_updatebase +{ + +} \ No newline at end of file diff --git a/src/menu.xml b/src/menu.xml new file mode 100644 index 0000000..41b7857 --- /dev/null +++ b/src/menu.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/metadata.php b/src/metadata.php index e9195a3..88e8ef0 100644 --- a/src/metadata.php +++ b/src/metadata.php @@ -15,11 +15,10 @@ * @link http://www.oxidmodule.com */ -use D3\Extsearch\setup as ModuleSetup; +use D3\Totp\Setup as ModuleSetup; use D3\ModCfg\Application\Model\d3utils; use OxidEsales\Eshop\Application\Controller\Admin\LoginController; use OxidEsales\Eshop\Core\Utils; -use OxidEsales\VisualCmsModule\Application\Controller\Admin\VisualCmsAdmin as VisualCMSAdmin; use OxidEsales\Eshop\Application\Controller as OxidController; use OxidEsales\Eshop\Application\Model as OxidModel; use OxidEsales\Eshop\Application\Component as OxidComponent; @@ -34,39 +33,49 @@ $sModuleId = 'd3totp'; /** * Module information */ -$aModule = array( +$aModule = [ 'id' => $sModuleId, 'title' => (class_exists(d3utils::class) ? d3utils::getInstance()->getD3Logo() : 'D³') . ' Zwei-Faktor-Authentisierung', - 'description' => array( + 'description' => [ 'de' => 'Zwei-Faktor-Authentisierung (TOTP) für OXID eSales Shop', 'en' => 'Two-factor authentication (TOTP) for OXID eSales shop', - ), + ], 'thumbnail' => 'picture.png', 'version' => '0.1', 'author' => 'D³ Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'http://www.oxidmodule.com/', - 'extend' => array( + 'extend' => [ //OxidModel\User::class => \D3\Totp\Modules\Application\Model\d3_totp_user::class, LoginController::class => \D3\Totp\Modules\Application\Controller\Admin\d3_totp_LoginController::class, Utils::class => \D3\Totp\Modules\Core\d3_totp_utils::class, - ), - 'controllers' => array( - ), - 'templates' => array( - ), - 'events' => [ ], - 'settings' => array( - ), - 'blocks' => array( - ), - 'd3FileRegister' => array( - ), - 'd3SetupClasses' => array( - ), -); + 'controllers' => [ + 'd3user_totp' => \D3\Totp\Application\Controller\Admin\d3user_totp::class + ], + 'templates' => [ + 'd3user_totp.tpl' => 'd3/totp/Application/views/admin/tpl/d3user_totp.tpl', + ], + 'events' => [ + 'onActivate' => '\D3\Totp\Setup\Events::onActivate', + 'onDeactivate' => '\D3\Totp\Setup\Events::onDeactivate', + ], + 'settings' => [ + ], + 'blocks' => [ + [ + 'template' => 'login.tpl', + 'block' => 'admin_login_form', + 'file' => 'Application/views/admin/blocks/d3totp_login_admin_login_form.tpl', + ] + ], + 'd3FileRegister' => [ + ], + 'd3SetupClasses' => [ + ModuleSetup\Installation::class + ] +]; // CREATE TABLE `d3totp` ( // `OXID` CHAR(32) NOT NULL, @@ -74,7 +83,7 @@ $aModule = array( // `USETOTP` TINYINT(1) NOT NULL DEFAULT '0', // `SEED` VARCHAR(100) NOT NULL DEFAULT '0', // PRIMARY KEY (`OXID`), -// UNIQUE INDEX `Schlüssel 2` (`OXUSERID`) +// UNIQUE INDEX `Schl�ssel 2` (`OXUSERID`) //) //ENGINE=InnoDB //; \ No newline at end of file