fix unthrown invalid totp exception
Cette révision appartient à :
Parent
42bab2bd25
révision
12bb6355ee
@ -179,10 +179,8 @@ class d3totpadminlogin extends AdminController
|
||||
*/
|
||||
public function d3TotpHasValidTotp(string $sTotp = null, d3totp $totp): bool
|
||||
{
|
||||
return $this->d3TotpGetSession()->getVariable(d3totp_conf::SESSION_AUTH) ||
|
||||
(
|
||||
$sTotp && $totp->verify($sTotp)
|
||||
);
|
||||
return $this->d3TotpGetSession()->getVariable(d3totp_conf::SESSION_AUTH)
|
||||
|| $totp->verify($sTotp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,7 +143,7 @@ class d3totp extends BaseModel
|
||||
{
|
||||
if (false == $this->totp) {
|
||||
$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'));
|
||||
}
|
||||
|
||||
|
@ -157,9 +157,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
|
||||
public function d3TotpHasValidTotp($sTotp, $totp)
|
||||
{
|
||||
return Registry::getSession()->getVariable(d3totp_conf::SESSION_AUTH) ||
|
||||
(
|
||||
$sTotp && $totp->verify($sTotp)
|
||||
);
|
||||
$totp->verify($sTotp);
|
||||
}
|
||||
|
||||
public function d3TotpClearSessionVariables()
|
||||
|
@ -537,11 +537,10 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
|
||||
->onlyMethods(['verify'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$oTotpMock->method('verify')->willReturn(true);
|
||||
$oTotpMock->method('verify')->willThrowException(oxNew(d3totp_wrongOtpException::class));
|
||||
|
||||
$this->assertFalse(
|
||||
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', [null, $oTotpMock])
|
||||
);
|
||||
$this->expectException(d3totp_wrongOtpException::class);
|
||||
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', [null, $oTotpMock]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -566,11 +566,10 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
->onlyMethods(['verify'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$oTotpMock->method('verify')->willReturn(true);
|
||||
$oTotpMock->method('verify')->willThrowException(oxNew(d3totp_wrongOtpException::class));
|
||||
|
||||
$this->assertFalse(
|
||||
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', [null, $oTotpMock])
|
||||
);
|
||||
$this->expectException(d3totp_wrongOtpException::class);
|
||||
$this->callMethod($this->_oController, 'd3TotpHasValidTotp', [null, $oTotpMock]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Chargement…
Référencer dans un nouveau ticket
Block a user