From 644ceaeca3bf28e469ce2a34fc8fdd90f326305a Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Sat, 20 Oct 2018 23:20:23 +0200 Subject: [PATCH] add cancel login action to login dialog, add translations --- .../Controller/Admin/d3user_totp.php | 2 +- .../blocks/d3totp_login_admin_login_form.tpl | 12 ++++++++++-- src/Application/views/admin/de/d3totp_lang.php | 4 +++- src/Application/views/admin/en/d3totp_lang.php | 18 ++++++++++++++++++ .../Admin/d3_totp_LoginController.php | 7 +++++++ src/metadata.php | 2 +- src/out/admin/src/css/d3totplogin.css | 12 ++++++++++++ 7 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 src/out/admin/src/css/d3totplogin.css diff --git a/src/Application/Controller/Admin/d3user_totp.php b/src/Application/Controller/Admin/d3user_totp.php index 7d30741..541b673 100644 --- a/src/Application/Controller/Admin/d3user_totp.php +++ b/src/Application/Controller/Admin/d3user_totp.php @@ -74,7 +74,7 @@ class d3user_totp extends AdminDetailsController /** @var d3_totp_user $oUser */ $oUser = oxNew(User::class); if (false == $oUser->d3CheckPasswordPass($this->getEditObjectId(), $pwd)) { - $oException = oxNew(StandardException::class, 'EXCEPTION_USER_PASSWORDDONTPASS'); + $oException = oxNew(StandardException::class, 'D3_TOTP_ERROR_PWDONTPASS'); throw $oException; } 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 index 5462e85..c578216 100644 --- a/src/Application/views/admin/blocks/d3totp_login_admin_login_form.tpl +++ b/src/Application/views/admin/blocks/d3totp_login_admin_login_form.tpl @@ -5,7 +5,7 @@ [{if $Errors.default|@count}] - [{include file="inc_error.tpl" Errorlist=$Errors.default}] + [{include file="inc_error.tpl" Errorlist=$Errors.default}] [{/if}] @@ -13,7 +13,15 @@ [{oxmultilang ident="TOTP_INPUT_HELP"}] - --Anmeldung abbrechen-- + [{* 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/src/Application/views/admin/de/d3totp_lang.php b/src/Application/views/admin/de/d3totp_lang.php index f45464d..8c2d4b6 100644 --- a/src/Application/views/admin/de/d3totp_lang.php +++ b/src/Application/views/admin/de/d3totp_lang.php @@ -21,7 +21,8 @@ $aLang = [ 'charset' => 'UTF-8', 'TOTP_INPUT' => 'Authentisierungscode', - 'TOTP_INPUT_HELP' => 'Den Authentisierungscode erhalten Sie von der Zweifaktorauthentisierung-App auf Ihrem Gerät.', + 'TOTP_INPUT_HELP' => 'Das Einmalpasswort erhalten Sie von der Zweifaktorauthentisierung-App auf Ihrem Gerät.', + 'TOTP_CANCEL_LOGIN' => 'Anmeldung abbrechen', 'd3mxuser_totp' => '2-Faktor-Authentisierung', @@ -40,4 +41,5 @@ $aLang = [ 'D3_TOTP_REGISTERDELETE_DESC' => 'Das Konto ist dann nicht mehr durch die Zweifaktorauthtisierung geschützt.', 'D3_TOTP_ERROR_UNVALID' => 'Das Einmalpasswort ist ungültig.', + 'D3_TOTP_ERROR_PWDONTPASS' => 'Das Passwort passt nicht zum gewählten Benutzerkonto.', ]; diff --git a/src/Application/views/admin/en/d3totp_lang.php b/src/Application/views/admin/en/d3totp_lang.php index fcd117f..53ab841 100644 --- a/src/Application/views/admin/en/d3totp_lang.php +++ b/src/Application/views/admin/en/d3totp_lang.php @@ -22,6 +22,24 @@ $aLang = [ 'TOTP_INPUT' => 'authentication code', 'TOTP_INPUT_HELP' => 'The authentication code is available from the Two-Factor Authentication app on your device.', + 'TOTP_CANCEL_LOGIN' => 'Cancel login', 'd3mxuser_totp' => 'Two-factor authentication', + + 'D3_TOTP_REGISTERNEW' => 'create new registration', + 'D3_TOTP_QRCODE' => 'QR code', + 'D3_TOTP_QRCODE_HELP' => 'Scan this QR code with your authentication app to deposit this user account.', + 'D3_TOTP_SECRET' => 'Can not scan QR code?', + 'D3_TOTP_SECRET_HELP' => 'If you do not use an app that can scan the QR code, you can also copy this string into your authentication tool. Please also set the password length to 6 characters and the time interval to 30 seconds.', + 'D3_TOTP_CURRPWD' => 'Login password of the user account', + 'D3_TOTP_CURRPWD_HELP' => 'The character string is stored encrypted in the shop. To encrypt, the password of the selected customer account is required. Concurrently, this ensures that only authorized users can make changes to these settings.', + 'D3_TOTP_CURROTP' => 'Confirmation with one-time password', + 'D3_TOTP_CURROTP_HELP' => 'If you have registered this customer account in your authentication app, you generate a one-time password, enter it here and send the form out immediately.', + + 'D3_TOTP_REGISTEREXIST' => 'existing registration', + 'D3_TOTP_REGISTERDELETE' => 'Delete registration', + 'D3_TOTP_REGISTERDELETE_DESC' => 'The account is then no longer protected by the two-factor authentication.', + + 'D3_TOTP_ERROR_UNVALID' => 'The one-time password is invalid.', + 'D3_TOTP_ERROR_PWDONTPASS' => 'The password does not match the selected user account.', ]; diff --git a/src/Modules/Application/Controller/Admin/d3_totp_LoginController.php b/src/Modules/Application/Controller/Admin/d3_totp_LoginController.php index 93def13..36e92be 100644 --- a/src/Modules/Application/Controller/Admin/d3_totp_LoginController.php +++ b/src/Modules/Application/Controller/Admin/d3_totp_LoginController.php @@ -18,6 +18,7 @@ namespace D3\Totp\Modules\Application\Controller\Admin; use D3\Totp\Application\Model\d3totp; use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException; use Doctrine\DBAL\DBALException; +use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Registry; @@ -106,4 +107,10 @@ class d3_totp_LoginController extends d3_totp_LoginController_parent $sTotp && $totp->verify($sTotp) ); } + + public function d3CancelLogin() + { + $oUser = oxNew(User::class); + $oUser->logout(); + } } \ No newline at end of file diff --git a/src/metadata.php b/src/metadata.php index 57d5c16..ff1d33a 100644 --- a/src/metadata.php +++ b/src/metadata.php @@ -36,7 +36,7 @@ $sModuleId = 'd3totp'; $aModule = [ 'id' => $sModuleId, 'title' => - (class_exists(d3utils::class) ? d3utils::getInstance()->getD3Logo() : 'D³') . ' Zwei-Faktor-Authentisierung', + (class_exists(d3utils::class) ? d3utils::getInstance()->getD3Logo() : 'D³') . ' Zwei-Faktor-Authentisierung / two-factor authentication', 'description' => [ 'de' => 'Zwei-Faktor-Authentisierung (TOTP) für OXID eSales Shop', 'en' => 'Two-factor authentication (TOTP) for OXID eSales shop', diff --git a/src/out/admin/src/css/d3totplogin.css b/src/out/admin/src/css/d3totplogin.css new file mode 100644 index 0000000..7f7dd62 --- /dev/null +++ b/src/out/admin/src/css/d3totplogin.css @@ -0,0 +1,12 @@ +#login { + display: flex; + flex-flow: column; +} +#login .btn { + order: 1; +} +#login .btn.btn_cancel { + order: 2; + background: lightblue; + color: black; +} \ No newline at end of file