Bugfix: 2FA enforcement #349

This commit is contained in:
the-djmaze 2022-05-20 12:36:30 +02:00
parent 01fe226a92
commit 656c5f2a3e
2 changed files with 13 additions and 8 deletions

View file

@ -7,9 +7,9 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
{ {
const const
NAME = 'Two Factor Authentication', NAME = 'Two Factor Authentication',
VERSION = '2.15.1', VERSION = '2.16',
RELEASE = '2022-05-02', RELEASE = '2022-05-20',
REQUIRED = '2.15.1', REQUIRED = '2.15.2',
CATEGORY = 'Login', CATEGORY = 'Login',
DESCRIPTION = 'Provides support for TOTP 2FA'; DESCRIPTION = 'Provides support for TOTP 2FA';
@ -52,7 +52,7 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
$aResult['SetupTwoFactor'] = false; $aResult['SetupTwoFactor'] = false;
if ($aResult['RequireTwoFactor'] && !empty($aResult['Auth'])) { if ($aResult['RequireTwoFactor'] && !empty($aResult['Auth'])) {
$aData = $this->getTwoFactorInfo($this->getMainAccountFromToken()); $aData = $this->getTwoFactorInfo($this->getMainAccountFromToken());
$aResult['SetupTwoFactor'] = empty($aResult['IsSet']) || empty($mData['Enable']); $aResult['SetupTwoFactor'] = empty($aData['IsSet']) || empty($aData['Enable']) || empty($aData['Secret']);
} }
} }
} }

View file

@ -106,7 +106,12 @@ class TwoFactorAuthSettings
} }
testTwoFactor() { testTwoFactor() {
TwoFactorAuthTestPopupView.showModal([this.twoFactorTested]); TwoFactorAuthTestPopupView.showModal([
() => {
this.twoFactorTested(true);
this.viewEnable(true);
}
]);
} }
clearTwoFactor() { clearTwoFactor() {
@ -188,15 +193,15 @@ class TwoFactorAuthTestPopupView extends rl.pluginPopupView {
Remote.verifyCode(iError => { Remote.verifyCode(iError => {
this.testing(false); this.testing(false);
this.codeStatus(!iError); this.codeStatus(!iError);
this.twoFactorTested(!iError); iError || (this.onSuccess() | this.close());
}, this.code()); }, this.code());
} }
onShow(twoFactorTested) { onShow(onSuccess) {
this.code(''); this.code('');
this.codeStatus(null); this.codeStatus(null);
this.testing(false); this.testing(false);
this.twoFactorTested = twoFactorTested; this.onSuccess = onSuccess;
} }
} }