diff --git a/src/Application/Model/d3totp.php b/src/Application/Model/d3totp.php
index 72f6568..81db88a 100644
--- a/src/Application/Model/d3totp.php
+++ b/src/Application/Model/d3totp.php
@@ -53,12 +53,17 @@ class d3totp extends BaseModel
{
$this->userId = $userId;
$oQB = d3database::getInstance()->getQueryBuilder();
- $oQB->select('oxid')
- ->from($this->getViewName())
- ->where("oxuserid = ".$oQB->createNamedParameter($userId))
- ->setMaxResults(1);
- return $this->load(DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getOne($oQB->getSQL(), $oQB->getParameters()));
+ if (DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getOne("SHOW TABLES LIKE 'd3totp'")) {
+ $oQB->select('oxid')
+ ->from($this->getViewName())
+ ->where("oxuserid = " . $oQB->createNamedParameter($userId))
+ ->setMaxResults(1);
+
+ return $this->load(DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getOne($oQB->getSQL(), $oQB->getParameters()));
+ }
+
+ return false;
}
/**
@@ -184,7 +189,7 @@ class d3totp extends BaseModel
{
$blVerify = $this->getTotp($seed)->verify($totp, null, 2);
if (false == $blVerify) {
- $oException = oxNew(d3totp_wrongOtpException::class, 'unvalid TOTP');
+ $oException = oxNew(d3totp_wrongOtpException::class, 'D3_TOTP_ERROR_UNVALID');
throw $oException;
}
diff --git a/src/Application/views/admin/de/d3totp_lang.php b/src/Application/views/admin/de/d3totp_lang.php
index 34f791f..f45464d 100644
--- a/src/Application/views/admin/de/d3totp_lang.php
+++ b/src/Application/views/admin/de/d3totp_lang.php
@@ -34,4 +34,10 @@ $aLang = [
'D3_TOTP_CURRPWD_HELP' => 'Die Zeichenkette wird verschlüsselt im Shop abgelegt. Zum Verschlüsseln wird das Passwort des ausgewählten Kundenkontos benötigt. Zugleich stellt dies sicher, dass nur Berechtigte Änderungen an diesen Einstellungen vornehmen dürfen.',
'D3_TOTP_CURROTP' => 'Bestätigung mit Einmalpasswort',
'D3_TOTP_CURROTP_HELP' => 'Haben Sie dieses Kundenkonto in Ihrer Authentisierungs-App registriert, generieren Sie damit ein Einmalpasswort, tragen Sie es hier ein und senden das Formular direkt darauf hin ab.',
+
+ 'D3_TOTP_REGISTEREXIST' => 'vorhandene Registrierung',
+ 'D3_TOTP_REGISTERDELETE' => 'Registrierung löschen',
+ 'D3_TOTP_REGISTERDELETE_DESC' => 'Das Konto ist dann nicht mehr durch die Zweifaktorauthtisierung geschützt.',
+
+ 'D3_TOTP_ERROR_UNVALID' => 'Das Einmalpasswort ist ungültig.',
];
diff --git a/src/Application/views/admin/tpl/d3user_totp.tpl b/src/Application/views/admin/tpl/d3user_totp.tpl
index f40e043..59af97a 100644
--- a/src/Application/views/admin/tpl/d3user_totp.tpl
+++ b/src/Application/views/admin/tpl/d3user_totp.tpl
@@ -52,6 +52,36 @@
[{oxinputhelp ident="D3_TOTP_QRCODE_HELP"}]
+ [{else}]
+
+
+ [{oxmultilang ident="D3_TOTP_REGISTEREXIST"}]
+ |
+
+
+
+
+ |
+
+ [{oxmultilang ident="D3_TOTP_REGISTERDELETE"}]
+ [{oxmultilang ident="D3_TOTP_REGISTERDELETE_DESC"}]
+ |
+
+ [{/if}]
+
+ [{/block}]
+
+
+
+
+
+ [{block name="user_d3user_totp_form2"}]
+ [{if false == $totp->getId()}]
+
+
+
+ |
+
@@ -81,15 +111,6 @@
[{oxinputhelp ident="D3_TOTP_CURROTP_HELP"}]
|
- [{else}]
-
-
-
- |
-
- neuen Zugang anlegen, alle bisherigen Zugännge werden damit ungültig
- |
-
[{/if}]
[{/block}]
@@ -101,12 +122,6 @@
|
-
-
-
- [{block name="user_d3user_totp_form2"}][{/block}]
-
- |
diff --git a/src/Modules/Application/Controller/Admin/d3_totp_LoginController.php b/src/Modules/Application/Controller/Admin/d3_totp_LoginController.php
index df0dec8..93def13 100644
--- a/src/Modules/Application/Controller/Admin/d3_totp_LoginController.php
+++ b/src/Modules/Application/Controller/Admin/d3_totp_LoginController.php
@@ -40,6 +40,7 @@ class d3_totp_LoginController extends d3_totp_LoginController_parent
if ($auth
&& $totp->UserUseTotp()
&& false == Registry::getSession()->getVariable(d3totp::TOTP_SESSION_VARNAME)
+ && Registry::getSession()->hasVariable('pwdTransmit')
) {
// set auth as secured parameter;
Registry::getSession()->setVariable("auth", $auth);
diff --git a/src/Setup/Installation.php b/src/Setup/Installation.php
index d7ad188..687be3f 100644
--- a/src/Setup/Installation.php
+++ b/src/Setup/Installation.php
@@ -15,9 +15,124 @@
namespace D3\Totp\Setup;
+use D3\ModCfg\Application\Model\d3database;
use D3\ModCfg\Application\Model\Install\d3install_updatebase;
+use Doctrine\DBAL\DBALException;
+use OxidEsales\Eshop\Core\Exception\ConnectionException;
+use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
+use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
class Installation extends d3install_updatebase
{
+ protected $_aUpdateMethods = array(
+ array('check' => 'doesTotpTableNotExist',
+ 'do' => 'addTotpTable'),
+ array('check' => 'checkFields',
+ 'do' => 'fixFields'),
+ array('check' => 'checkIndizes',
+ 'do' => 'fixIndizes'),
+ );
+ // Standardwerte für checkMultiLangTables() und fixRegisterMultiLangTables()
+ public $aMultiLangTables = array();
+
+ public $aFields = array(
+ 'OXID' => array(
+ 'sTableName' => 'd3totp',
+ 'sFieldName' => 'OXID',
+ 'sType' => 'CHAR(32)',
+ 'blNull' => false,
+ 'sDefault' => false,
+ 'sComment' => '',
+ 'sExtra' => '',
+ 'blMultilang' => false,
+ ),
+ 'OXUSERID' => array(
+ 'sTableName' => 'd3totp',
+ 'sFieldName' => 'OXUSERID',
+ 'sType' => 'CHAR(32)',
+ 'blNull' => false,
+ 'sDefault' => false,
+ 'sComment' => '',
+ 'sExtra' => '',
+ 'blMultilang' => false,
+ ),
+ 'USETOTP' => array(
+ 'sTableName' => 'd3totp',
+ 'sFieldName' => 'USETOTP',
+ 'sType' => 'TINYINT(1)',
+ 'blNull' => false,
+ 'sDefault' => 0,
+ 'sComment' => '',
+ 'sExtra' => '',
+ 'blMultilang' => false,
+ ),
+ 'SEED' => array(
+ 'sTableName' => 'd3totp',
+ 'sFieldName' => 'SEED',
+ 'sType' => 'VARCHAR(256)',
+ 'blNull' => false,
+ 'sDefault' => false,
+ 'sComment' => '',
+ 'sExtra' => '',
+ 'blMultilang' => false,
+ )
+ );
+
+ public $aIndizes = array(
+ 'OXID' => array(
+ 'sTableName' => 'd3totp',
+ 'sType' => d3database::INDEX_TYPE_PRIMARY,
+ 'sName' => 'PRIMARY',
+ 'aFields' => array(
+ 'OXID' => 'OXID',
+ ),
+ ),
+ 'OXUSERID' => array(
+ 'sTableName' => 'd3totp',
+ 'sType' => d3database::INDEX_TYPE_UNIQUE,
+ 'sName' => 'OXUSERID',
+ 'aFields' => array(
+ 'OXUSERID' => 'OXUSERID',
+ ),
+ )
+ );
+
+ protected $_aRefreshMetaModuleIds = array('d3ordermanager');
+
+
+ /**
+ * @return bool
+ * @throws DBALException
+ * @throws DatabaseConnectionException
+ * @throws DatabaseErrorException
+ */
+ public function doesTotpTableNotExist()
+ {
+ return $this->_checkTableNotExist('d3totp');
+ }
+
+ /**
+ * @return bool
+ * @throws ConnectionException
+ * @throws DBALException
+ * @throws DatabaseConnectionException
+ * @throws DatabaseErrorException
+ */
+ public function addTotpTable()
+ {
+ $blRet = false;
+ if ($this->doesTotpTableNotExist()) {
+ $this->setInitialExecMethod(__METHOD__);
+ $blRet = $this->_addTable2(
+ 'd3totp',
+ $this->aFields,
+ $this->aIndizes,
+ 'totp setting',
+ 'InnoDB'
+ );
+ }
+
+ return $blRet;
+ }
}
\ No newline at end of file