Added "Enforce 2-Step verification" setting

This commit is contained in:
RainLoop Team 2015-04-07 20:39:43 +04:00
parent b7709c8117
commit acb013fbb5
47 changed files with 1271 additions and 908 deletions

View file

@ -1306,6 +1306,7 @@ class Actions
'RegistrationLinkUrl' => \trim($oConfig->Get('login', 'registration_link_url', '')),
'ContactsIsAllowed' => false,
'ChangePasswordIsAllowed' => false,
'RequireTwoFactor' => false,
'JsHash' => \md5(\RainLoop\Utils::GetConnectionToken()),
'UseImapThread' => (bool) $oConfig->Get('labs', 'use_imap_thread', false),
'UseImapSubscribe' => (bool) $oConfig->Get('labs', 'use_imap_list_subscribe', true),
@ -1479,6 +1480,20 @@ class Actions
}
$aResult['Capa'] = $this->Capa(false, $oAccount);
if ($aResult['Auth'] && !$aResult['RequireTwoFactor'])
{
if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::TWO_FACTOR, $oAccount) &&
$this->GetCapa(false, \RainLoop\Enumerations\Capa::TWO_FACTOR_FORCE, $oAccount) &&
$this->TwoFactorAuthProvider()->IsActive())
{
$aData = $this->getTwoFactorInfo($oAccount, true);
$aResult['RequireTwoFactor'] = !$aData ||
!isset($aData['User'], $aData['IsSet'], $aData['Enable']) ||
!($aData['IsSet'] && $aData['Enable']);
}
}
}
else
{
@ -3111,6 +3126,9 @@ class Actions
case \RainLoop\Enumerations\Capa::TWO_FACTOR:
$this->setConfigFromParams($oConfig, $sParamName, 'security', 'allow_two_factor_auth', 'bool');
break;
case \RainLoop\Enumerations\Capa::TWO_FACTOR_FORCE:
$this->setConfigFromParams($oConfig, $sParamName, 'security', 'force_two_factor_auth', 'bool');
break;
case \RainLoop\Enumerations\Capa::GRAVATAR:
$this->setConfigFromParams($oConfig, $sParamName, 'labs', 'allow_gravatar', 'bool');
break;
@ -3216,6 +3234,7 @@ class Actions
$this->setCapaFromParams($oConfig, 'CapaAdditionalAccounts', \RainLoop\Enumerations\Capa::ADDITIONAL_ACCOUNTS);
$this->setCapaFromParams($oConfig, 'CapaTemplates', \RainLoop\Enumerations\Capa::TEMPLATES);
$this->setCapaFromParams($oConfig, 'CapaTwoFactorAuth', \RainLoop\Enumerations\Capa::TWO_FACTOR);
$this->setCapaFromParams($oConfig, 'CapaTwoFactorAuthForce', \RainLoop\Enumerations\Capa::TWO_FACTOR_FORCE);
$this->setCapaFromParams($oConfig, 'CapaOpenPGP', \RainLoop\Enumerations\Capa::OPEN_PGP);
$this->setCapaFromParams($oConfig, 'CapaGravatar', \RainLoop\Enumerations\Capa::GRAVATAR);
$this->setCapaFromParams($oConfig, 'CapaThemes', \RainLoop\Enumerations\Capa::THEMES);
@ -7772,6 +7791,12 @@ class Actions
($bAdmin || ($oAccount && !$oAccount->IsAdditionalAccount())))
{
$aResult[] = \RainLoop\Enumerations\Capa::TWO_FACTOR;
if ($oConfig->Get('security', 'force_two_factor_auth', false) &&
($bAdmin || ($oAccount && !$oAccount->IsAdditionalAccount())))
{
$aResult[] = \RainLoop\Enumerations\Capa::TWO_FACTOR_FORCE;
}
}
if ($oConfig->Get('labs', 'allow_gravatar', false))