improve code syntax
This commit is contained in:
parent
a9a279a753
commit
f14ce58d6e
@ -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'));
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ class d3_totp_UserComponent extends d3_totp_UserComponent_parent
|
||||
protected function _afterLogin($oUser)
|
||||
{
|
||||
if (!$oUser instanceof User) {
|
||||
throw oxNew( InvalidArgumentException::class, 'user argument must an instance of User class');
|
||||
throw oxNew(InvalidArgumentException::class, 'user argument must an instance of User class');
|
||||
}
|
||||
|
||||
if ($oUser->getId()) {
|
||||
|
@ -99,7 +99,7 @@ class d3_totp_LoginController extends d3_totp_LoginController_parent
|
||||
}
|
||||
|
||||
$myUtilsServer->setOxCookie("oxidadminlanguage", $aLanguages[$iLang]->abbr, time() + 31536000, "/");
|
||||
$this->d3TotpGetLangObject()->setTplLanguage( $iLang);
|
||||
$this->d3TotpGetLangObject()->setTplLanguage($iLang);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,8 @@ trait d3_totp_getUserTrait
|
||||
|
||||
if ($totp->isActive()
|
||||
&& !$this->d3TotpGetSessionObject()->getVariable(
|
||||
isAdmin() ? d3totp_conf::SESSION_ADMIN_AUTH : d3totp_conf::SESSION_AUTH)
|
||||
isAdmin() ? d3totp_conf::SESSION_ADMIN_AUTH : d3totp_conf::SESSION_AUTH
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
@ -69,14 +69,14 @@ $aModule = [
|
||||
LoginController::class => d3_totp_LoginController::class,
|
||||
Utils::class => d3_totp_utils::class,
|
||||
UserComponent::class => d3_totp_UserComponent::class,
|
||||
SystemEventHandler::class => totpSystemEventHandler::class
|
||||
SystemEventHandler::class => totpSystemEventHandler::class,
|
||||
],
|
||||
'controllers' => [
|
||||
'd3user_totp' => d3user_totp::class,
|
||||
'd3force_2fa' => d3force_2fa::class,
|
||||
'd3totplogin' => d3totplogin::class,
|
||||
'd3_account_totp' => d3_account_totp::class,
|
||||
'd3totpadminlogin' => d3totpadminlogin::class
|
||||
'd3totpadminlogin' => d3totpadminlogin::class,
|
||||
],
|
||||
'templates' => [
|
||||
'd3user_totp.tpl' => 'd3/totp/Application/views/admin/tpl/d3user_totp.tpl',
|
||||
|
@ -117,11 +117,11 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
|
||||
/** @var Session|MockObject $oSessionMock */
|
||||
$oSessionMock = $this->getMockBuilder(Session::class)
|
||||
->onlyMethods([
|
||||
'hasVariable'
|
||||
'hasVariable',
|
||||
])
|
||||
->getMock();
|
||||
$hasVariableMap = [
|
||||
[d3totp_conf::SESSION_ADMIN_AUTH, $hasAuthAlready]
|
||||
[d3totp_conf::SESSION_ADMIN_AUTH, $hasAuthAlready],
|
||||
];
|
||||
$oSessionMock->method('hasVariable')->willReturnMap($hasVariableMap);
|
||||
|
||||
@ -129,7 +129,7 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
|
||||
$oControllerMock = $this->getMockBuilder(d3totpadminlogin::class)
|
||||
->onlyMethods([
|
||||
'd3TotpGetSession',
|
||||
'd3TotpGetTotpObject'
|
||||
'd3TotpGetTotpObject',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
|
||||
@ -173,7 +173,7 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
|
||||
/** @var Session|MockObject $oSessionMock */
|
||||
$oSessionMock = $this->getMockBuilder(Session::class)
|
||||
->onlyMethods([
|
||||
'hasVariable'
|
||||
'hasVariable',
|
||||
])
|
||||
->getMock();
|
||||
$hasVariableMap = [
|
||||
@ -185,7 +185,7 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
|
||||
/** @var d3totpadminlogin|MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMockBuilder(d3totpadminlogin::class)
|
||||
->onlyMethods([
|
||||
'd3TotpGetSession'
|
||||
'd3TotpGetSession',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
|
||||
@ -244,7 +244,7 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
|
||||
'isTotpIsNotRequired',
|
||||
'isTotpLoginNotPossible',
|
||||
'd3TotpGetUtils',
|
||||
'd3GetLoginController'
|
||||
'd3GetLoginController',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('isTotpIsNotRequired')->willReturn($totpRequired);
|
||||
@ -431,7 +431,7 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
|
||||
'getLogger',
|
||||
'd3TotpHasValidTotp',
|
||||
'd3TotpGetSession',
|
||||
'd3GetLoginController'
|
||||
'd3GetLoginController',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('d3TotpHasValidTotp')
|
||||
@ -494,7 +494,7 @@ class d3totpadminloginTest extends d3TotpUnitTestCase
|
||||
'getLogger',
|
||||
'd3TotpHasValidTotp',
|
||||
'd3TotpGetSession',
|
||||
'd3GetLoginController'
|
||||
'd3GetLoginController',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('d3TotpHasValidTotp')->willReturn(true);
|
||||
|
@ -77,7 +77,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
|
||||
$oControllerMock->method('d3TotpGetUtils')->willReturn($oUtilsMock);
|
||||
|
||||
$this->expectException( InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
$this->callMethod($oControllerMock, '_afterLogin', [$oUser]);
|
||||
}
|
||||
@ -204,7 +204,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
'd3GetTotpObject',
|
||||
'd3TotpGetSession',
|
||||
'd3TotpGetUtils',
|
||||
'getParent'
|
||||
'getParent',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
@ -358,7 +358,7 @@ class d3_totp_UserComponentTest extends d3TotpUnitTestCase
|
||||
'd3TotpGetUtilsView',
|
||||
'd3GetTotpObject',
|
||||
'd3TotpGetSession',
|
||||
'setLoginStatus'
|
||||
'setLoginStatus',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('d3TotpIsNoTotpOrNoLogin')->willReturn(false);
|
||||
|
@ -165,7 +165,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
return [
|
||||
'no profile selected' => [null, $this->once(), '', $this->never()],
|
||||
'valid profile selected' => [2, $this->once(), '2@geh@2', $this->once()],
|
||||
'invalid profile selected' => [5, $this->never(), false, $this->never()]
|
||||
'invalid profile selected' => [5, $this->never(), false, $this->never()],
|
||||
];
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
/** @var d3_totp_LoginController|MockObject $oControllerMock */
|
||||
$oControllerMock = $this->getMockBuilder(d3_totp_LoginController::class)
|
||||
->onlyMethods([
|
||||
'd3TotpGetSession'
|
||||
'd3TotpGetSession',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->method('d3TotpGetSession')->willReturn($oSessionMock);
|
||||
@ -272,8 +272,8 @@ class d3_totp_LoginControllerTest extends d3TotpUnitTestCase
|
||||
{
|
||||
return [
|
||||
'totp not active, not logged in'=> [false, false, false],
|
||||
'totp active, logged in' => [true , true, false],
|
||||
'totp active, not logged in' => [true , false, true],
|
||||
'totp active, logged in' => [true, true, false],
|
||||
'totp active, not logged in' => [true, false, true],
|
||||
'totp not active, logged in' => [false, true, false],
|
||||
];
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ trait d3_totp_getUserTestTrait
|
||||
->onlyMethods([
|
||||
'd3GetTotpObject',
|
||||
'd3TotpGetSessionObject',
|
||||
'd3CallMockableParent'
|
||||
'd3CallMockableParent',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
@ -135,7 +135,7 @@ trait d3_totp_getUserTestTrait
|
||||
->onlyMethods([
|
||||
'd3GetTotpObject',
|
||||
'd3TotpGetSessionObject',
|
||||
'd3CallMockableParent'
|
||||
'd3CallMockableParent',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
@ -185,7 +185,7 @@ trait d3_totp_getUserTestTrait
|
||||
->onlyMethods([
|
||||
'd3GetTotpObject',
|
||||
'd3TotpGetSessionObject',
|
||||
'd3CallMockableParent'
|
||||
'd3CallMockableParent',
|
||||
])
|
||||
->getMock();
|
||||
$oControllerMock->expects($this->once())->method('d3GetTotpObject')->willReturn($oTotpMock);
|
||||
|
@ -94,7 +94,7 @@ class totpSystemEventHandlerTest extends UnitTestCase
|
||||
/** @var totpSystemEventHandler|MockObject $sut */
|
||||
$sut = $this->getMockBuilder(SystemEventHandler::class)
|
||||
->onlyMethods(['d3GetTotpObject', 'd3TotpGetSession', 'd3TotpLoginMissing',
|
||||
'd3TotpGetUserObject', 'getUtilsObject'])
|
||||
'd3TotpGetUserObject', 'getUtilsObject', ])
|
||||
->getMock();
|
||||
$sut->method('d3GetTotpObject')->willReturn($totpMock);
|
||||
$sut->method('d3TotpGetSession')->willReturn($sessionMock);
|
||||
@ -115,7 +115,7 @@ class totpSystemEventHandlerTest extends UnitTestCase
|
||||
{
|
||||
return [
|
||||
'no totp missing' => [false, $this->never(), $this->never()],
|
||||
'totp missing' => [true, $this->once(), $this->once()]
|
||||
'totp missing' => [true, $this->once(), $this->once()],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user