fix unthrown invalid totp exception
This commit is contained in:
parent
42bab2bd25
commit
12bb6355ee
@ -179,10 +179,8 @@ class d3totpadminlogin extends AdminController
|
|||||||
*/
|
*/
|
||||||
public function d3TotpHasValidTotp(string $sTotp = null, d3totp $totp): bool
|
public function d3TotpHasValidTotp(string $sTotp = null, d3totp $totp): bool
|
||||||
{
|
{
|
||||||
return $this->d3TotpGetSession()->getVariable(d3totp_conf::SESSION_AUTH) ||
|
return $this->d3TotpGetSession()->getVariable(d3totp_conf::SESSION_AUTH)
|
||||||
(
|
|| $totp->verify($sTotp);
|
||||||
$sTotp && $totp->verify($sTotp)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,7 +143,7 @@ class d3totp extends BaseModel
|
|||||||
{
|
{
|
||||||
if (false == $this->totp) {
|
if (false == $this->totp) {
|
||||||
$this->totp = TOTP::create($seed ?: $this->getSavedSecret());
|
$this->totp = TOTP::create($seed ?: $this->getSavedSecret());
|
||||||
$this->totp->setLabel($this->getUser()->getFieldData('oxusername'));
|
$this->totp->setLabel($this->getUser()->getFieldData('oxusername')?: '');
|
||||||
$this->totp->setIssuer(Registry::getConfig()->getActiveShop()->getFieldData('oxname'));
|
$this->totp->setIssuer(Registry::getConfig()->getActiveShop()->getFieldData('oxname'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,9 +157,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
|
|||||||
public function d3TotpHasValidTotp($sTotp, $totp)
|
public function d3TotpHasValidTotp($sTotp, $totp)
|
||||||
{
|
{
|
||||||
return Registry::getSession()->getVariable(d3totp_conf::SESSION_AUTH) ||
|
return Registry::getSession()->getVariable(d3totp_conf::SESSION_AUTH) ||
|
||||||
(
|
$totp->verify($sTotp);
|
||||||
$sTotp && $totp->verify($sTotp)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function d3TotpClearSessionVariables()
|
public function d3TotpClearSessionVariables()
|
||||||
|
@ -537,11 +537,10 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
|
|||||||
->onlyMethods(['verify'])
|
->onlyMethods(['verify'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$oTotpMock->method('verify')->willReturn(true);
|
$oTotpMock->method('verify')->willThrowException(oxNew(d3totp_wrongOtpException::class));
|
||||||
|
|
||||||
$this->assertFalse(
|
$this->expectException(d3totp_wrongOtpException::class);
|
||||||
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', [null, $oTotpMock])
|
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', [null, $oTotpMock]);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -566,11 +566,10 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
|||||||
->onlyMethods(['verify'])
|
->onlyMethods(['verify'])
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$oTotpMock->method('verify')->willReturn(true);
|
$oTotpMock->method('verify')->willThrowException(oxNew(d3totp_wrongOtpException::class));
|
||||||
|
|
||||||
$this->assertFalse(
|
$this->expectException(d3totp_wrongOtpException::class);
|
||||||
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', [null, $oTotpMock])
|
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', [null, $oTotpMock]);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user