add available backup code message in backend and in login form

This commit is contained in:
2019-07-28 23:34:39 +02:00
parent a42121b4bc
commit 1ed760f8e4
7 changed files with 70 additions and 8 deletions

View File

@ -16,6 +16,7 @@
namespace D3\Totp\Modules\Application\Controller\Admin;
use D3\Totp\Application\Model\d3totp;
use D3\Totp\Application\Model\Exceptions\d3backupcodelist;
use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException;
use Doctrine\DBAL\DBALException;
use OxidEsales\Eshop\Application\Model\User;
@ -78,6 +79,25 @@ class d3_totp_LoginController extends d3_totp_LoginController_parent
return $return;
}
/**
* @return string|void
* @throws DatabaseConnectionException
*/
public function getBackupCodeCountMessage()
{
$oBackupCodeList = oxNew(d3backupcodelist::class);
$iCount = $oBackupCodeList->getAvailableCodeCount(Registry::getSession()->getVariable("auth"));
if ($iCount < 4) {
return sprintf(
Registry::getLang()->translateString('D3_TOTP_AVAILBACKUPCODECOUNT'),
$iCount
);
};
return;
}
/**
* @param d3totp $totp
* @return bool