From bedb60928de2ae28cb6d662e621bc8554550666b Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Fri, 6 Sep 2024 07:54:55 +0200 Subject: [PATCH] add Twig templates --- .../Controller/Admin/d3totpadminlogin.php | 3 +- Application/Controller/Admin/d3user_totp.php | 3 +- Application/Controller/d3_account_totp.php | 3 +- Application/Controller/d3totplogin.php | 3 +- Application/Model/Constants.php | 23 +++ metadata.php | 28 ++- .../{d3totplogin.tpl => d3totpadminlogin.tpl} | 0 views/twig/admin/d3totplogin.html.twig | 127 ++++++++++++ views/twig/admin/d3totplogin.tpl | 126 ++++++++++++ views/twig/admin/d3user_totp.html.twig | 194 ++++++++++++++++++ views/twig/admin/d3user_totp.tpl | 194 ++++++++++++++++++ .../d3totp_login_admin_login_form.html.twig | 29 +++ .../admin/d3totp_login_admin_login_form.tpl | 29 +++ .../account_dashboard_col2_flow.html.twig | 11 + .../account/account_dashboard_col2_flow.tpl | 11 + .../account_dashboard_col2_wave.html.twig | 11 + .../account/account_dashboard_col2_wave.tpl | 11 + .../page/account/inc/account_menu.html.twig | 4 + .../wave/page/account/inc/account_menu.tpl | 4 + .../widget_header_servicebox_items.html.twig | 4 + .../header/widget_header_servicebox_items.tpl | 4 + views/twig/wave/d3_account_totp.html.twig | 150 ++++++++++++++ views/twig/wave/d3_account_totp.tpl | 149 ++++++++++++++ views/twig/wave/d3totpadminlogin.html.twig | 92 +++++++++ views/twig/wave/d3totplogin.tpl | 91 ++++++++ 25 files changed, 1284 insertions(+), 20 deletions(-) create mode 100644 Application/Model/Constants.php rename views/smarty/wave/{d3totplogin.tpl => d3totpadminlogin.tpl} (100%) create mode 100644 views/twig/admin/d3totplogin.html.twig create mode 100644 views/twig/admin/d3totplogin.tpl create mode 100644 views/twig/admin/d3user_totp.html.twig create mode 100644 views/twig/admin/d3user_totp.tpl create mode 100644 views/twig/extensions/admin/d3totp_login_admin_login_form.html.twig create mode 100644 views/twig/extensions/admin/d3totp_login_admin_login_form.tpl create mode 100644 views/twig/extensions/wave/page/account/account_dashboard_col2_flow.html.twig create mode 100644 views/twig/extensions/wave/page/account/account_dashboard_col2_flow.tpl create mode 100644 views/twig/extensions/wave/page/account/account_dashboard_col2_wave.html.twig create mode 100644 views/twig/extensions/wave/page/account/account_dashboard_col2_wave.tpl create mode 100644 views/twig/extensions/wave/page/account/inc/account_menu.html.twig create mode 100644 views/twig/extensions/wave/page/account/inc/account_menu.tpl create mode 100644 views/twig/extensions/wave/widget/header/widget_header_servicebox_items.html.twig create mode 100644 views/twig/extensions/wave/widget/header/widget_header_servicebox_items.tpl create mode 100644 views/twig/wave/d3_account_totp.html.twig create mode 100644 views/twig/wave/d3_account_totp.tpl create mode 100644 views/twig/wave/d3totpadminlogin.html.twig create mode 100644 views/twig/wave/d3totplogin.tpl diff --git a/Application/Controller/Admin/d3totpadminlogin.php b/Application/Controller/Admin/d3totpadminlogin.php index f6a13f5..0095f0c 100644 --- a/Application/Controller/Admin/d3totpadminlogin.php +++ b/Application/Controller/Admin/d3totpadminlogin.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace D3\Totp\Application\Controller\Admin; +use D3\Totp\Application\Model\Constants; use D3\Totp\Application\Model\d3backupcodelist; use D3\Totp\Application\Model\d3totp; use D3\Totp\Application\Model\d3totp_conf; @@ -32,7 +33,7 @@ use Psr\Log\LoggerInterface; class d3totpadminlogin extends AdminController { - protected $_sThisTemplate = 'd3totpadminlogin.tpl'; + protected $_sThisTemplate = '@'.Constants::OXID_MODULE_ID.'/wave/d3totpadminlogin'; /** * @return bool diff --git a/Application/Controller/Admin/d3user_totp.php b/Application/Controller/Admin/d3user_totp.php index 82e5acf..d882ace 100644 --- a/Application/Controller/Admin/d3user_totp.php +++ b/Application/Controller/Admin/d3user_totp.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace D3\Totp\Application\Controller\Admin; +use D3\Totp\Application\Model\Constants; use D3\Totp\Application\Model\d3totp; use D3\Totp\Application\Model\d3backupcodelist; use D3\Totp\Modules\Application\Model\d3_totp_user; @@ -30,7 +31,7 @@ class d3user_totp extends AdminDetailsController { protected $_sSaveError = null; - protected $_sThisTemplate = 'd3user_totp.tpl'; + protected $_sThisTemplate = '@'.Constants::OXID_MODULE_ID.'/admin/d3user_totp'; public $aBackupCodes = []; diff --git a/Application/Controller/d3_account_totp.php b/Application/Controller/d3_account_totp.php index f5aea45..c11325c 100644 --- a/Application/Controller/d3_account_totp.php +++ b/Application/Controller/d3_account_totp.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace D3\Totp\Application\Controller; +use D3\Totp\Application\Model\Constants; use D3\Totp\Application\Model\d3backupcodelist; use D3\Totp\Application\Model\d3totp; use D3\Totp\Modules\Application\Model\d3_totp_user; @@ -27,7 +28,7 @@ use OxidEsales\Eshop\Core\UtilsView; class d3_account_totp extends AccountController { - protected $_sThisTemplate = 'd3_account_totp.tpl'; + protected $_sThisTemplate = '@'.Constants::OXID_MODULE_ID.'/wave/d3_account_totp'; public $aBackupCodes = []; diff --git a/Application/Controller/d3totplogin.php b/Application/Controller/d3totplogin.php index 9094f80..982f7a1 100644 --- a/Application/Controller/d3totplogin.php +++ b/Application/Controller/d3totplogin.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace D3\Totp\Application\Controller; +use D3\Totp\Application\Model\Constants; use D3\Totp\Application\Model\d3backupcodelist; use D3\Totp\Application\Model\d3totp_conf; use OxidEsales\Eshop\Application\Controller\FrontendController; @@ -24,7 +25,7 @@ use OxidEsales\Eshop\Core\Utils; class d3totplogin extends FrontendController { - protected $_sThisTemplate = 'd3totplogin.tpl'; + protected $_sThisTemplate = '@'.Constants::OXID_MODULE_ID.'/admin/d3totplogin'; public function render() { diff --git a/Application/Model/Constants.php b/Application/Model/Constants.php new file mode 100644 index 0000000..2cc36c2 --- /dev/null +++ b/Application/Model/Constants.php @@ -0,0 +1,23 @@ + + * @link https://www.oxidmodule.com + */ + +declare(strict_types=1); + +namespace D3\Totp\Application\Model; + +class Constants +{ + public const OXID_MODULE_ID = 'd3totp'; +} diff --git a/metadata.php b/metadata.php index 2faac84..2eae174 100644 --- a/metadata.php +++ b/metadata.php @@ -18,6 +18,7 @@ use D3\Totp\Application\Controller\Admin\d3user_totp; use D3\Totp\Application\Controller\Admin\d3force_2fa; use D3\Totp\Application\Controller\d3_account_totp; use D3\Totp\Application\Controller\d3totplogin; +use D3\Totp\Application\Model\Constants; use D3\Totp\Modules\Application\Component\d3_totp_UserComponent; use D3\Totp\Modules\Application\Controller\Admin\d3_totp_LoginController; use D3\Totp\Modules\Application\Controller\d3_totp_OrderController; @@ -36,22 +37,13 @@ use OxidEsales\Eshop\Core\SystemEventHandler; use OxidEsales\Eshop\Core\Utils; use OxidEsales\Eshop\Application\Model as OxidModel; -/** - * Metadata version - */ $sMetadataVersion = '2.1'; -$sModuleId = 'd3totp'; -$logo = '(D3)'; - -/** - * Module information - */ $aModule = [ - 'id' => $sModuleId, + 'id' => Constants::OXID_MODULE_ID, 'title' => [ - 'de' => $logo . ' zweiter Faktor - Einmalpasswort', - 'en' => $logo . ' second factor - one-time password', + 'de' => '(D3) zweiter Faktor - Einmalpasswort', + 'en' => '(D3) second factor - one-time password', ], 'description' => [ 'de' => 'Einmalpasswort (TOTP) als zweiter Faktor bei der Anmeldung im OXID eSales Shop', @@ -80,10 +72,14 @@ $aModule = [ 'd3totpadminlogin' => d3totpadminlogin::class, ], 'templates' => [ - 'd3user_totp.tpl' => 'd3/totp/Application/views/admin/tpl/d3user_totp.tpl', - 'd3totplogin.tpl' => 'd3/totp/Application/views/tpl/d3totplogin.tpl', - 'd3_account_totp.tpl' => 'd3/totp/Application/views/tpl/d3_account_totp.tpl', - 'd3totpadminlogin.tpl' => 'd3/totp/Application/views/admin/tpl/d3totplogin.tpl', +// 'd3user_totp.tpl' => 'd3/totp/Application/views/admin/tpl/d3user_totp.tpl', + '@'.Constants::OXID_MODULE_ID.'/admin/d3user_totp.tpl' => 'views/smarty/admin/d3user_totp.tpl', + '@'.Constants::OXID_MODULE_ID.'/admin/d3totplogin.tpl' => 'views/smarty/admin/d3totplogin.tpl', +// 'd3totplogin.tpl' => 'd3/totp/Application/views/tpl/d3totplogin.tpl', +// 'd3_account_totp.tpl' => 'd3/totp/Application/views/tpl/d3_account_totp.tpl', + '@'.Constants::OXID_MODULE_ID.'/wave/d3_account_totp.tpl' => 'views/smarty/wave/d3_account_totp.tpl', + '@'.Constants::OXID_MODULE_ID.'/wave/d3totpadminlogin.tpl' => 'views/smarty/wave/d3totpadminlogin.tpl', +// 'd3totpadminlogin.tpl' => 'd3/totp/Application/views/admin/tpl/d3totplogin.tpl', ], 'settings' => [ [ diff --git a/views/smarty/wave/d3totplogin.tpl b/views/smarty/wave/d3totpadminlogin.tpl similarity index 100% rename from views/smarty/wave/d3totplogin.tpl rename to views/smarty/wave/d3totpadminlogin.tpl diff --git a/views/twig/admin/d3totplogin.html.twig b/views/twig/admin/d3totplogin.html.twig new file mode 100644 index 0000000..a6f88b0 --- /dev/null +++ b/views/twig/admin/d3totplogin.html.twig @@ -0,0 +1,127 @@ + + + + {{ translate({ ident: "LOGIN_TITLE" }) }} + + + + + + + + +
+ + + +
+ + {% block admin_login_form %} + {{ oViewConf.getHiddenSid()|raw }} + + + + + + +

{{ translate({ ident: "TOTP_INPUT" }) }}

+ + {% if not empty(Errors.default) %} + {% include "inc_error.html.twig" with {Errorlist: Errors.default} %} + {% endif %} + + {{ oView.getBackupCodeCountMessage() }} + +
+ + + + + + + + + + + + +
+ + {% capture name = "d3js" %} + function clickEvent(previous, next){ + const digitKeys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; + const deleteKeys = ['Backspace', 'Delete']; + if(next && digitKeys.includes(event.key)){ + document.getElementById(next).focus(); + } else if(previous && deleteKeys.includes(event.key)){ + document.getElementById(previous).focus(); + } + } + document.addEventListener("paste", function(e) { + if (e.target.type is same as("text") { +) + var data = e.clipboardData.getData('Text'); + data = data.split(''); + [].forEach.call(document.querySelectorAll("#login input[type=text]"), (node, index) => { + node.value = data[index]; + }); + } + }); + {% endcapture %} + {{ script({ add: smarty.capture.d3js, dynamic: __oxid_include_dynamic }) }} + +
{{ translate({ ident: "TOTP_INPUT_HELP" }) }}
+ +
+ + + + {{ style({ include: oViewConf.getModuleUrl('d3totp',, out/admin/src/css/d3totplogin.css'): 'out/admin/src/css/d3totplogin.css') }) }} + {{ style() }} + + + +{# * + + + + + + {{ oViewConf.getHiddenSid()|raw }} + + + + + {% if not empty(Errors.default) %} + {% include "inc_error.html.twig" with {Errorlist: Errors.default} %} + {% endif %} + +
+
+ {% include $oViewConf->getModulePath('d3webauthn', with {out/img/fingerprint.svg'): 'out/img/fingerprint.svg')} %} +
+
{{ translate({ ident: "WEBAUTHN_INPUT_HELP" }) }}
+
+* #} + {# prevent cancel button (1st button) action when form is sent via Enter key #} +{# * + + + + + {{ style({ include: oViewConf.getModuleUrl('d3webauthn',, out/admin/src/css/d3webauthnlogin.css'): 'out/admin/src/css/d3webauthnlogin.css') }) }} + {{ style() }} +* #} + {% endblock %} +
+
+ +{{ script({ dynamic: __oxid_include_dynamic }) }} + + + + diff --git a/views/twig/admin/d3totplogin.tpl b/views/twig/admin/d3totplogin.tpl new file mode 100644 index 0000000..6dd26e1 --- /dev/null +++ b/views/twig/admin/d3totplogin.tpl @@ -0,0 +1,126 @@ + + + + [{oxmultilang ident="LOGIN_TITLE"}] + + + + + + + + +
+ + + +
+ + [{block name="admin_login_form"}] + [{$oViewConf->getHiddenSid()}] + + + + + + +

[{oxmultilang ident="TOTP_INPUT"}]

+ + [{if !empty($Errors.default)}] + [{include file="inc_error.tpl" Errorlist=$Errors.default}] + [{/if}] + + [{$oView->getBackupCodeCountMessage()}] + +
+ + + + + + + + + + + + +
+ + [{capture name="d3js"}] + function clickEvent(previous, next){ + const digitKeys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; + const deleteKeys = ['Backspace', 'Delete']; + if(next && digitKeys.includes(event.key)){ + document.getElementById(next).focus(); + } else if(previous && deleteKeys.includes(event.key)){ + document.getElementById(previous).focus(); + } + } + document.addEventListener("paste", function(e) { + if (e.target.type === "text") { + var data = e.clipboardData.getData('Text'); + data = data.split(''); + [].forEach.call(document.querySelectorAll("#login input[type=text]"), (node, index) => { + node.value = data[index]; + }); + } + }); + [{/capture}] + [{oxscript add=$smarty.capture.d3js}] + +
[{oxmultilang ident="TOTP_INPUT_HELP"}]
+ +
+ + + + [{oxstyle include=$oViewConf->getModuleUrl('d3totp', 'out/admin/src/css/d3totplogin.css')}] + [{oxstyle}] + + + +[{** + + + + + + [{$oViewConf->getHiddenSid()}] + + + + + [{if !empty($Errors.default)}] + [{include file="inc_error.tpl" Errorlist=$Errors.default}] + [{/if}] + +
+
+ [{include file=$oViewConf->getModulePath('d3webauthn', 'out/img/fingerprint.svg')}] +
+
[{oxmultilang ident="WEBAUTHN_INPUT_HELP"}]
+
+**}] + [{* prevent cancel button (1st button) action when form is sent via Enter key *}] +[{** + + + + + [{oxstyle include=$oViewConf->getModuleUrl('d3webauthn', 'out/admin/src/css/d3webauthnlogin.css')}] + [{oxstyle}] +**}] + [{/block}] +
+
+ +[{oxscript}] + + + + diff --git a/views/twig/admin/d3user_totp.html.twig b/views/twig/admin/d3user_totp.html.twig new file mode 100644 index 0000000..0ff81de --- /dev/null +++ b/views/twig/admin/d3user_totp.html.twig @@ -0,0 +1,194 @@ +{% include "headitem.html.twig" with {title: "GENERAL_ADMIN_TITLE"|translate} %} + +{{ style({ include: "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" }) }} +{{ script({ include: "https://code.jquery.com/jquery-3.2.1.slim.min.js", dynamic: __oxid_include_dynamic }) }} +{{ script({ include: "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js", dynamic: __oxid_include_dynamic }) }} +{{ script({ include: "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js", dynamic: __oxid_include_dynamic }) }} +{{ style({ include: "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/solid.min.css" }) }} +{{ style() }} + +{% set totp = edit.d3GetTotp() %} +{% set userid = edit.getId() %} +{{ totp.loadByUserId(userid) }} + +{% if readonly %} + {% set readonly = "readonly disabled" %} +{% else %} + {% set readonly = "" %} +{% endif %} + + + +{% if force2FA %} +
+

{{ translate({ ident: "D3_TOTP_FORCE2FATITLE" }) }}

+
{{ translate({ ident: "D3_TOTP_FORCE2FASUB" }) }}
+
+{% endif %} + +
+ {{ oViewConf.getHiddenSid()|raw }} + + +
+ +
+ {{ oViewConf.getHiddenSid()|raw }} + + + + + + + {% if sSaveError %} + + + + + +
{{ translate({ ident: sSaveError }) }}
+ {% endif %} + + {% if oxid and oxid != ' - 1' %} +
+
+
+
+ {% block user_d3user_totp_form1 %} + {% if false == totp.getId() %} +
+ {{ translate({ ident: "D3_TOTP_REGISTERNEW" }) }} +
+
+
+
+ {{ translate({ ident: "D3_TOTP_QRCODE", suffix: "COLON" }) }} +
+
+ {{ totp.getQrCodeElement()|raw }} + {% include "inputhelp.html.twig" with {'sHelpId': help_id("D3_TOTP_QRCODE_HELP"), 'sHelpText': help_text("D3_TOTP_QRCODE_HELP")} %} +
+
+
+ {% elseif force2FA %} +
+ {{ translate({ ident: "D3_TOTP_ADMINBACKEND" }) }} +
+
+ +
+ {% else %} +
+ {{ translate({ ident: "D3_TOTP_REGISTEREXIST" }) }} +
+
+
+
+ {{ translate({ ident: "D3_TOTP_REGISTERDELETE_DESC" }) }} +
+
+ +
+
+
+
+ {% endif %} + {% endblock %} +
+
+
+
+ {% block user_d3user_totp_form2 %} + {% if false == totp.getId() %} +
+ {{ translate({ ident: "D3_TOTP_CONFIRMATION" }) }} +
+
+
+
+ +
+
+ + {% include "inputhelp.html.twig" with {'sHelpId': help_id("D3_TOTP_SECRET_HELP"), 'sHelpText': help_text("D3_TOTP_SECRET_HELP")} %} +
+
+
+
+ +
+
+ + {% include "inputhelp.html.twig" with {'sHelpId': help_id("D3_TOTP_CURROTP_HELP"), 'sHelpText': help_text("D3_TOTP_CURROTP_HELP")} %} +
+
+
+
+
+ +
+
+
+ {% else %} +
+ {{ translate({ ident: "D3_TOTP_BACKUPCODES" }) }} +
+
+ {% if oView.getBackupCodes() %} +
+
+ +
+
+ +
+
+ {% else %} +
+
+ {{ translate({ ident: "D3_TOTP_AVAILBACKUPCODECOUNT", args: oView.getAvailableBackupCodeCount() }) }} +
+
+ {{ translate({ ident: "D3_TOTP_AVAILBACKUPCODECOUNT_DESC" }) }} +
+
+ {% endif %} +
+ {% endif %} + {% endblock %} +
+
+
+
+ {% endif %} +
+ +{% if not force2FA %} + {% include "bottomnaviitem.html.twig" %} + {% include "bottomitem.html.twig" %} +{% endif %} diff --git a/views/twig/admin/d3user_totp.tpl b/views/twig/admin/d3user_totp.tpl new file mode 100644 index 0000000..999662b --- /dev/null +++ b/views/twig/admin/d3user_totp.tpl @@ -0,0 +1,194 @@ +[{include file="headitem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign}] + +[{oxstyle include="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"}] +[{oxscript include="https://code.jquery.com/jquery-3.2.1.slim.min.js"}] +[{oxscript include="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"}] +[{oxscript include="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"}] +[{oxstyle include="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/solid.min.css"}] +[{oxstyle}] + +[{assign var="totp" value=$edit->d3GetTotp()}] +[{assign var="userid" value=$edit->getId()}] +[{$totp->loadByUserId($userid)}] + +[{if $readonly}] + [{assign var="readonly" value="readonly disabled"}] +[{else}] + [{assign var="readonly" value=""}] +[{/if}] + + + +[{if $force2FA}] +
+

[{oxmultilang ident="D3_TOTP_FORCE2FATITLE"}]

+
[{oxmultilang ident="D3_TOTP_FORCE2FASUB"}]
+
+[{/if}] + +
+ [{$oViewConf->getHiddenSid()}] + + +
+ +
+ [{$oViewConf->getHiddenSid()}] + + + + + + + [{if $sSaveError}] + + + + + +
[{oxmultilang ident=$sSaveError}]
+ [{/if}] + + [{if $oxid && $oxid != '-1'}] +
+
+
+
+ [{block name="user_d3user_totp_form1"}] + [{if false == $totp->getId()}] +
+ [{oxmultilang ident="D3_TOTP_REGISTERNEW"}] +
+
+
+
+ [{oxmultilang ident="D3_TOTP_QRCODE" suffix="COLON"}] +
+
+ [{$totp->getQrCodeElement()}] + [{oxinputhelp ident="D3_TOTP_QRCODE_HELP"}] +
+
+
+ [{elseif $force2FA}] +
+ [{oxmultilang ident="D3_TOTP_ADMINBACKEND"}] +
+
+ +
+ [{else}] +
+ [{oxmultilang ident="D3_TOTP_REGISTEREXIST"}] +
+
+
+
+ [{oxmultilang ident="D3_TOTP_REGISTERDELETE_DESC"}] +
+
+ +
+
+
+
+ [{/if}] + [{/block}] +
+
+
+
+ [{block name="user_d3user_totp_form2"}] + [{if false == $totp->getId()}] +
+ [{oxmultilang ident="D3_TOTP_CONFIRMATION"}] +
+
+
+
+ +
+
+ + [{oxinputhelp ident="D3_TOTP_SECRET_HELP"}] +
+
+
+
+ +
+
+ + [{oxinputhelp ident="D3_TOTP_CURROTP_HELP"}] +
+
+
+
+
+ +
+
+
+ [{else}] +
+ [{oxmultilang ident="D3_TOTP_BACKUPCODES"}] +
+
+ [{if $oView->getBackupCodes()}] +
+
+ +
+
+ +
+
+ [{else}] +
+
+ [{oxmultilang ident="D3_TOTP_AVAILBACKUPCODECOUNT" args=$oView->getAvailableBackupCodeCount()}] +
+
+ [{oxmultilang ident="D3_TOTP_AVAILBACKUPCODECOUNT_DESC"}] +
+
+ [{/if}] +
+ [{/if}] + [{/block}] +
+
+
+
+ [{/if}] +
+ +[{if !$force2FA}] + [{include file="bottomnaviitem.tpl"}] + [{include file="bottomitem.tpl"}] +[{/if}] diff --git a/views/twig/extensions/admin/d3totp_login_admin_login_form.html.twig b/views/twig/extensions/admin/d3totp_login_admin_login_form.html.twig new file mode 100644 index 0000000..edb55c9 --- /dev/null +++ b/views/twig/extensions/admin/d3totp_login_admin_login_form.html.twig @@ -0,0 +1,29 @@ +{% if request_totp %} + {{ oViewConf.getHiddenSid()|raw }} + + + + + {% if not empty(Errors.default) %} + {% include "inc_error.html.twig" with {Errorlist: Errors.default} %} + {% endif %} + + {{ oView.getBackupCodeCountMessage() }} + + +
+ + {{ translate({ ident: "TOTP_INPUT_HELP" }) }} + + {# prevent cancel button (1st button) action when form is sent via Enter key #} + + + + + {{ style({ include: oViewConf.getModuleUrl('d3totp',, out/admin/src/css/d3totplogin.css'): 'out/admin/src/css/d3totplogin.css') }) }} + {{ style() }} +{% else %} + {{ parent() }} +{% endif %} \ No newline at end of file diff --git a/views/twig/extensions/admin/d3totp_login_admin_login_form.tpl b/views/twig/extensions/admin/d3totp_login_admin_login_form.tpl new file mode 100644 index 0000000..f24b1db --- /dev/null +++ b/views/twig/extensions/admin/d3totp_login_admin_login_form.tpl @@ -0,0 +1,29 @@ +[{if $request_totp}] + [{$oViewConf->getHiddenSid()}] + + + + + [{if !empty($Errors.default)}] + [{include file="inc_error.tpl" Errorlist=$Errors.default}] + [{/if}] + + [{$oView->getBackupCodeCountMessage()}] + + +
+ + [{oxmultilang ident="TOTP_INPUT_HELP"}] + + [{* prevent cancel button (1st button) action when form is sent via Enter key *}] + + + + + [{oxstyle include=$oViewConf->getModuleUrl('d3totp', 'out/admin/src/css/d3totplogin.css')}] + [{oxstyle}] +[{else}] + [{$smarty.block.parent}] +[{/if}] \ No newline at end of file diff --git a/views/twig/extensions/wave/page/account/account_dashboard_col2_flow.html.twig b/views/twig/extensions/wave/page/account/account_dashboard_col2_flow.html.twig new file mode 100644 index 0000000..f647bba --- /dev/null +++ b/views/twig/extensions/wave/page/account/account_dashboard_col2_flow.html.twig @@ -0,0 +1,11 @@ +{{ parent() }} + +
+ +
{{ translate({ ident: "D3_TOTP_ACCOUNT_DESC" }) }}
+
\ No newline at end of file diff --git a/views/twig/extensions/wave/page/account/account_dashboard_col2_flow.tpl b/views/twig/extensions/wave/page/account/account_dashboard_col2_flow.tpl new file mode 100644 index 0000000..8084fde --- /dev/null +++ b/views/twig/extensions/wave/page/account/account_dashboard_col2_flow.tpl @@ -0,0 +1,11 @@ +[{$smarty.block.parent}] + +
+ +
[{oxmultilang ident="D3_TOTP_ACCOUNT_DESC"}]
+
\ No newline at end of file diff --git a/views/twig/extensions/wave/page/account/account_dashboard_col2_wave.html.twig b/views/twig/extensions/wave/page/account/account_dashboard_col2_wave.html.twig new file mode 100644 index 0000000..bf09fd2 --- /dev/null +++ b/views/twig/extensions/wave/page/account/account_dashboard_col2_wave.html.twig @@ -0,0 +1,11 @@ +{{ parent() }} + +
+ +
{{ translate({ ident: "D3_TOTP_ACCOUNT_DESC" }) }}
+
\ No newline at end of file diff --git a/views/twig/extensions/wave/page/account/account_dashboard_col2_wave.tpl b/views/twig/extensions/wave/page/account/account_dashboard_col2_wave.tpl new file mode 100644 index 0000000..15bed23 --- /dev/null +++ b/views/twig/extensions/wave/page/account/account_dashboard_col2_wave.tpl @@ -0,0 +1,11 @@ +[{$smarty.block.parent}] + +
+ +
[{oxmultilang ident="D3_TOTP_ACCOUNT_DESC"}]
+
\ No newline at end of file diff --git a/views/twig/extensions/wave/page/account/inc/account_menu.html.twig b/views/twig/extensions/wave/page/account/inc/account_menu.html.twig new file mode 100644 index 0000000..da7092d --- /dev/null +++ b/views/twig/extensions/wave/page/account/inc/account_menu.html.twig @@ -0,0 +1,4 @@ +{{ parent() }} + \ No newline at end of file diff --git a/views/twig/extensions/wave/page/account/inc/account_menu.tpl b/views/twig/extensions/wave/page/account/inc/account_menu.tpl new file mode 100644 index 0000000..deaa83b --- /dev/null +++ b/views/twig/extensions/wave/page/account/inc/account_menu.tpl @@ -0,0 +1,4 @@ +[{$smarty.block.parent}] + \ No newline at end of file diff --git a/views/twig/extensions/wave/widget/header/widget_header_servicebox_items.html.twig b/views/twig/extensions/wave/widget/header/widget_header_servicebox_items.html.twig new file mode 100644 index 0000000..5c24b32 --- /dev/null +++ b/views/twig/extensions/wave/widget/header/widget_header_servicebox_items.html.twig @@ -0,0 +1,4 @@ +{{ parent() }} +
  • + {{ translate({ ident: "D3_TOTP_ACCOUNT" }) }} +
  • \ No newline at end of file diff --git a/views/twig/extensions/wave/widget/header/widget_header_servicebox_items.tpl b/views/twig/extensions/wave/widget/header/widget_header_servicebox_items.tpl new file mode 100644 index 0000000..d90c7a3 --- /dev/null +++ b/views/twig/extensions/wave/widget/header/widget_header_servicebox_items.tpl @@ -0,0 +1,4 @@ +[{$smarty.block.parent}] +
  • + [{oxmultilang ident="D3_TOTP_ACCOUNT"}] +
  • \ No newline at end of file diff --git a/views/twig/wave/d3_account_totp.html.twig b/views/twig/wave/d3_account_totp.html.twig new file mode 100644 index 0000000..2159afe --- /dev/null +++ b/views/twig/wave/d3_account_totp.html.twig @@ -0,0 +1,150 @@ +{% capture append = "oxidBlock_content" %} + +

    {{ translate({ ident: "D3_TOTP_ACCOUNT" }) }}

    + + {% set totp = user.d3GetTotp() %} + {% set userid = user.getId() %} + {{ totp.loadByUserId(userid) }} + + + + {% block d3_account_totp %} +
    + + +

    + + +

    + + {% if false == totp.getId() %} +
    +
    + {{ translate({ ident: "D3_TOTP_REGISTERNEW" }) }} +
    +
    +
    +
    + {{ translate({ ident: "D3_TOTP_QRCODE" }) }}  +
    +
    + {{ totp.getQrCodeElement() }} +
    +
    +

    + {{ translate({ ident: "D3_TOTP_QRCODE_HELP" }) }} +

    + +
    + +
    +
    + +
    +
    + +
    +
    +

    + {{ translate({ ident: "D3_TOTP_SECRET_HELP" }) }} +

    + +
    + +
    +
    + +
    +
    + +
    +
    +

    + {{ translate({ ident: "D3_TOTP_CURROTP_HELP" }) }} +

    +
    +
    + {% endif %} + + {% if totp.getId() %} + {% block d3_account_totp_deletenotes %} +
    +
    + {{ translate({ ident: "D3_TOTP_REGISTEREXIST" }) }} +
    +
    + {{ translate({ ident: "D3_TOTP_REGISTERDELETE_DESC" }) }} +
    +
    + {% endblock %} + + {% block d3_account_totp_backupcodes %} +
    +
    + {{ translate({ ident: "D3_TOTP_BACKUPCODES" }) }} +
    +
    + {% if oView.getBackupCodes() %} + {% block d3_account_totp_backupcodes_list %} + + + {% endblock %} + {% else %} + {% block d3_account_totp_backupcodes_info %} + {{ translate({ ident: "D3_TOTP_AVAILBACKUPCODECOUNT", args: oView.getAvailableBackupCodeCount() }) }}
    + {{ translate({ ident: "D3_TOTP_AVAILBACKUPCODECOUNT_DESC" }) }} + {% endblock %} + {% endif %} +
    +
    + {% endblock %} + {% endif %} + +

    + +

    +
    + {% endblock %} +{% endcapture %} + +{% capture append = "oxidBlock_sidebar" %} + {% include "page/account/inc/account_menu.html.twig" with {active_link: "d3totp"} %} +{% endcapture %} +{% include "layout/page.html.twig" with {sidebar: "Left"} %} \ No newline at end of file diff --git a/views/twig/wave/d3_account_totp.tpl b/views/twig/wave/d3_account_totp.tpl new file mode 100644 index 0000000..0362b79 --- /dev/null +++ b/views/twig/wave/d3_account_totp.tpl @@ -0,0 +1,149 @@ +[{capture append="oxidBlock_content"}] + +

    [{oxmultilang ident="D3_TOTP_ACCOUNT"}]

    + + [{assign var="totp" value=$user->d3GetTotp()}] + [{assign var="userid" value=$user->getId()}] + [{$totp->loadByUserId($userid)}] + + + + [{block name="d3_account_totp"}] +
    + + +

    + getId()}] checked[{/if}] [{if false == $totp->getId()}]onclick="$('.registerNew').toggle(); $('.submitBtn').toggle();"[{/if}]> + +

    + + [{if false == $totp->getId()}] +
    +
    + [{oxmultilang ident="D3_TOTP_REGISTERNEW"}] +
    +
    +
    +
    + [{oxmultilang ident="D3_TOTP_QRCODE"}]  +
    +
    + [{$totp->getQrCodeElement()}] +
    +
    +

    + [{oxmultilang ident="D3_TOTP_QRCODE_HELP"}] +

    + +
    + +
    +
    + +
    +
    + +
    +
    +

    + [{oxmultilang ident="D3_TOTP_SECRET_HELP"}] +

    + +
    + +
    +
    + +
    +
    + +
    +
    +

    + [{oxmultilang ident="D3_TOTP_CURROTP_HELP"}] +

    +
    +
    + [{/if}] + + [{if $totp->getId()}] + [{block name="d3_account_totp_deletenotes"}] +
    +
    + [{oxmultilang ident="D3_TOTP_REGISTEREXIST"}] +
    +
    + [{oxmultilang ident="D3_TOTP_REGISTERDELETE_DESC"}] +
    +
    + [{/block}] + + [{block name="d3_account_totp_backupcodes"}] +
    +
    + [{oxmultilang ident="D3_TOTP_BACKUPCODES"}] +
    +
    + [{if $oView->getBackupCodes()}] + [{block name="d3_account_totp_backupcodes_list"}] + + + [{/block}] + [{else}] + [{block name="d3_account_totp_backupcodes_info"}] + [{oxmultilang ident="D3_TOTP_AVAILBACKUPCODECOUNT" args=$oView->getAvailableBackupCodeCount()}]
    + [{oxmultilang ident="D3_TOTP_AVAILBACKUPCODECOUNT_DESC"}] + [{/block}] + [{/if}] +
    +
    + [{/block}] + [{/if}] + +

    + +

    +
    + [{/block}] +[{/capture}] + +[{capture append="oxidBlock_sidebar"}] + [{include file="page/account/inc/account_menu.tpl" active_link="d3totp"}] +[{/capture}] +[{include file="layout/page.tpl" sidebar="Left"}] \ No newline at end of file diff --git a/views/twig/wave/d3totpadminlogin.html.twig b/views/twig/wave/d3totpadminlogin.html.twig new file mode 100644 index 0000000..0423ba4 --- /dev/null +++ b/views/twig/wave/d3totpadminlogin.html.twig @@ -0,0 +1,92 @@ +{% capture append = "oxidBlock_content" %} + {% set template_title = "" %} + + {% if oView.previousClassIsOrderStep() %} + {# ordering steps #} + {% include "page/checkout/inc/steps.html.twig" with {active: 2} %} + {% endif %} + +
    +
    +
    + {{ oViewConf.getHiddenSid()|raw }} + + + + {{ navFormParams }} + +

    {{ translate({ ident: "D3_TOTP_INPUT" }) }}

    + + {% if not empty(Errors.default) %} + {% include "inc_error.html.twig" with {Errorlist: Errors.default} %} + {% endif %} + + {{ oView.getBackupCodeCountMessage() }} + +
    + + + + + + + + + + + + +
    + + {% capture name = "d3js" %} + function clickEvent(previous, next){ + const digitKeys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; + const deleteKeys = ['Backspace', 'Delete']; + if(next && digitKeys.includes(event.key)){ + document.getElementById(next).focus(); + } else if(previous && deleteKeys.includes(event.key)){ + document.getElementById(previous).focus(); + } + } + document.addEventListener("paste", function(e) { + if (e.target.type is same as("text") { +) + var data = e.clipboardData.getData('Text'); + data = data.split(''); + [].forEach.call(document.querySelectorAll("#login input[type=text]"), (node, index) => { + node.value = data[index]; + }); + } + }); + {% endcapture %} + {{ script({ add: smarty.capture.d3js, dynamic: __oxid_include_dynamic }) }} + +
    {{ translate({ ident: "D3_TOTP_INPUT_HELP" }) }}
    + +
    + +
    +
    + {{ oViewConf.getHiddenSid()|raw }} + + + + {{ navFormParams }} + + + +
    +
    +
    + + {{ style({ include: oViewConf.getModuleUrl('d3totp',, out/flow/src/css/d3totplogin.css'): 'out/flow/src/css/d3totplogin.css') }) }} + {{ style() }} + + {{ insert_tracker({title: template_title}) }} +{% endcapture %} + +{% include "layout/page.html.twig" %} \ No newline at end of file diff --git a/views/twig/wave/d3totplogin.tpl b/views/twig/wave/d3totplogin.tpl new file mode 100644 index 0000000..c6ec44d --- /dev/null +++ b/views/twig/wave/d3totplogin.tpl @@ -0,0 +1,91 @@ +[{capture append="oxidBlock_content"}] + [{assign var="template_title" value=""}] + + [{if $oView->previousClassIsOrderStep()}] + [{* ordering steps *}] + [{include file="page/checkout/inc/steps.tpl" active=2}] + [{/if}] + +
    +
    +
    + [{$oViewConf->getHiddenSid()}] + + + + [{$navFormParams}] + +

    [{oxmultilang ident="D3_TOTP_INPUT"}]

    + + [{if !empty($Errors.default)}] + [{include file="inc_error.tpl" Errorlist=$Errors.default}] + [{/if}] + + [{$oView->getBackupCodeCountMessage()}] + +
    + + + + + + + + + + + + +
    + + [{capture name="d3js"}] + function clickEvent(previous, next){ + const digitKeys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; + const deleteKeys = ['Backspace', 'Delete']; + if(next && digitKeys.includes(event.key)){ + document.getElementById(next).focus(); + } else if(previous && deleteKeys.includes(event.key)){ + document.getElementById(previous).focus(); + } + } + document.addEventListener("paste", function(e) { + if (e.target.type === "text") { + var data = e.clipboardData.getData('Text'); + data = data.split(''); + [].forEach.call(document.querySelectorAll("#login input[type=text]"), (node, index) => { + node.value = data[index]; + }); + } + }); + [{/capture}] + [{oxscript add=$smarty.capture.d3js}] + +
    [{oxmultilang ident="D3_TOTP_INPUT_HELP"}]
    + +
    + +
    +
    + [{$oViewConf->getHiddenSid()}] + + + + [{$navFormParams}] + + + +
    +
    +
    + + [{oxstyle include=$oViewConf->getModuleUrl('d3totp', 'out/flow/src/css/d3totplogin.css')}] + [{oxstyle}] + + [{insert name="oxid_tracker" title=$template_title}] +[{/capture}] + +[{include file="layout/page.tpl"}] \ No newline at end of file