move unvalid totp message to exception

This commit is contained in:
Daniel Seifert 2018-10-20 23:39:22 +02:00
parent 644ceaeca3
commit 19b3dc7881
2 changed files with 278 additions and 268 deletions

View File

@ -28,5 +28,15 @@ use OxidEsales\Eshop\Core\Exception\StandardException;
class d3totp_wrongOtpException extends StandardException
{
/**
* Default constructor
*
* @param string $sMessage exception message
* @param integer $iCode exception code
* @param \Exception|null $previous previous exception
*/
public function __construct($sMessage = "D3_TOTP_ERROR_UNVALID", $iCode = 0, \Exception $previous = null)
{
parent::__construct($sMessage, $iCode, $previous);
}
}

View File

@ -54,7 +54,7 @@ class d3totp extends BaseModel
$this->userId = $userId;
$oQB = d3database::getInstance()->getQueryBuilder();
if (DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getOne("SHOW TABLES LIKE 'd3totp'")) {
if (DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getOne("SHOW TABLES LIKE '".$this->tableName."'")) {
$oQB->select('oxid')
->from($this->getViewName())
->where("oxuserid = " . $oQB->createNamedParameter($userId))
@ -189,7 +189,7 @@ class d3totp extends BaseModel
{
$blVerify = $this->getTotp($seed)->verify($totp, null, 2);
if (false == $blVerify) {
$oException = oxNew(d3totp_wrongOtpException::class, 'D3_TOTP_ERROR_UNVALID');
$oException = oxNew(d3totp_wrongOtpException::class);
throw $oException;
}