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

@ -28,11 +28,27 @@
this.weakPassword = AppAdminStore.weakPassword;
this.capaOpenPGP = CapaAdminStore.openPGP;
this.capaTwoFactorAuth = CapaAdminStore.twoFactorAuth;
this.capaTwoFactorAuthForce = CapaAdminStore.twoFactorAuthForce;
this.capaTwoFactorAuth.subscribe(function (bValue) {
if (!bValue)
{
this.capaTwoFactorAuthForce(false);
}
}, this);
this.verifySslCertificate = ko.observable(!!Settings.settingsGet('VerifySslCertificate'));
this.allowSelfSigned = ko.observable(!!Settings.settingsGet('AllowSelfSigned'));
this.verifySslCertificate.subscribe(function (bValue) {
if (!bValue)
{
this.allowSelfSigned(true);
}
}, this);
this.adminLogin = ko.observable(Settings.settingsGet('AdminLogin'));
this.adminLoginError = ko.observable(false);
this.adminPassword = ko.observable('');
@ -126,6 +142,12 @@
});
});
this.capaTwoFactorAuthForce.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'CapaTwoFactorAuthForce': bValue ? '1' : '0'
});
});
this.useLocalProxyForExternalImages.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'UseLocalProxyForExternalImages': bValue ? '1' : '0'

View file

@ -39,180 +39,15 @@
{'id': 60, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 60})}
];
});
this.processing = ko.observable(false);
this.clearing = ko.observable(false);
this.secreting = ko.observable(false);
this.viewUser = ko.observable('');
this.twoFactorStatus = ko.observable(false);
this.twoFactorTested = ko.observable(false);
this.viewSecret = ko.observable('');
this.viewBackupCodes = ko.observable('');
this.viewUrl = ko.observable('');
this.viewEnable_ = ko.observable(false);
this.viewEnable = ko.computed({
'owner': this,
'read': this.viewEnable_,
'write': function (bValue) {
var self = this;
bValue = !!bValue;
if (bValue && this.twoFactorTested())
{
this.viewEnable_(bValue);
Remote.enableTwoFactor(function (sResult, oData) {
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{
self.viewEnable_(false);
}
}, true);
}
else
{
if (!bValue)
{
this.viewEnable_(bValue);
}
Remote.enableTwoFactor(function (sResult, oData) {
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{
self.viewEnable_(false);
}
}, false);
}
}
});
this.viewTwoFactorEnableTooltip = ko.computed(function () {
Translator.trigger();
return this.twoFactorTested() || this.viewEnable_() ? '' :
Translator.i18n('SETTINGS_SECURITY/TWO_FACTOR_SECRET_TEST_BEFORE_DESC');
}, this);
this.viewTwoFactorStatus = ko.computed(function () {
Translator.trigger();
return Translator.i18n(
this.twoFactorStatus() ?
'SETTINGS_SECURITY/TWO_FACTOR_SECRET_CONFIGURED_DESC' :
'SETTINGS_SECURITY/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC'
);
}, this);
this.twoFactorAllowedEnable = ko.computed(function () {
return this.viewEnable() || this.twoFactorTested();
}, this);
this.onResult = _.bind(this.onResult, this);
this.onShowSecretResult = _.bind(this.onShowSecretResult, this);
}
SecurityUserSettings.prototype.showSecret = function ()
SecurityUserSettings.prototype.configureTwoFactor = function ()
{
this.secreting(true);
Remote.showTwoFactorSecret(this.onShowSecretResult);
};
SecurityUserSettings.prototype.hideSecret = function ()
{
this.viewSecret('');
this.viewBackupCodes('');
this.viewUrl('');
};
SecurityUserSettings.prototype.createTwoFactor = function ()
{
this.processing(true);
Remote.createTwoFactor(this.onResult);
};
SecurityUserSettings.prototype.testTwoFactor = function ()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/TwoFactorTest'), [this.twoFactorTested]);
};
SecurityUserSettings.prototype.clearTwoFactor = function ()
{
this.viewSecret('');
this.viewBackupCodes('');
this.viewUrl('');
this.twoFactorTested(false);
this.clearing(true);
Remote.clearTwoFactor(this.onResult);
};
SecurityUserSettings.prototype.onShow = function ()
{
this.viewSecret('');
this.viewBackupCodes('');
this.viewUrl('');
};
SecurityUserSettings.prototype.onResult = function (sResult, oData)
{
this.processing(false);
this.clearing(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.viewUser(Utils.pString(oData.Result.User));
this.viewEnable_(!!oData.Result.Enable);
this.twoFactorStatus(!!oData.Result.IsSet);
this.twoFactorTested(!!oData.Result.Tested);
this.viewSecret(Utils.pString(oData.Result.Secret));
this.viewBackupCodes(Utils.pString(oData.Result.BackupCodes).replace(/[\s]+/g, ' '));
this.viewUrl(Utils.pString(oData.Result.Url));
}
else
{
this.viewUser('');
this.viewEnable_(false);
this.twoFactorStatus(false);
this.twoFactorTested(false);
this.viewSecret('');
this.viewBackupCodes('');
this.viewUrl('');
}
};
SecurityUserSettings.prototype.onShowSecretResult = function (sResult, oData)
{
this.secreting(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.viewSecret(Utils.pString(oData.Result.Secret));
this.viewUrl(Utils.pString(oData.Result.Url));
}
else
{
this.viewSecret('');
this.viewUrl('');
}
require('Knoin/Knoin').showScreenPopup(require('View/Popup/TwoFactorConfiguration'));
};
SecurityUserSettings.prototype.onBuild = function ()
{
if (this.capaTwoFactor)
{
this.processing(true);
Remote.getTwoFactor(this.onResult);
}
if (this.capaAutoLogout)
{
var self = this;