Enhancement to Two Factor Auth (Closes #131)

This commit is contained in:
RainLoop Team 2014-04-15 01:58:27 +04:00
parent e211899c7b
commit 365a79049e
30 changed files with 359 additions and 208 deletions

View file

@ -7,6 +7,7 @@ function SettingsSecurity()
{
this.processing = ko.observable(false);
this.clearing = ko.observable(false);
this.secreting = ko.observable(false);
this.viewUser = ko.observable('');
this.viewEnable = ko.observable(false);
@ -29,10 +30,24 @@ function SettingsSecurity()
}, this);
this.onResult = _.bind(this.onResult, this);
this.onSecretResult = _.bind(this.onSecretResult, this);
}
Utils.addSettingsViewModel(SettingsSecurity, 'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security');
SettingsSecurity.prototype.showSecret = function ()
{
this.secreting(true);
RL.remote().showTwoFactorSecret(this.onSecretResult);
};
SettingsSecurity.prototype.hideSecret = function ()
{
this.viewSecret('');
this.viewBackupCodes('');
this.viewUrl('');
};
SettingsSecurity.prototype.createTwoFactor = function ()
{
this.processing(true);
@ -113,6 +128,22 @@ SettingsSecurity.prototype.onResult = function (sResult, oData)
}
};
SettingsSecurity.prototype.onSecretResult = 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('');
}
};
SettingsSecurity.prototype.onBuild = function ()
{
this.processing(true);

View file

@ -72,6 +72,14 @@ WebMailAjaxRemoteStorage.prototype.clearTwoFactor = function (fCallback)
this.defaultRequest(fCallback, 'ClearTwoFactorInfo');
};
/**
* @param {?Function} fCallback
*/
WebMailAjaxRemoteStorage.prototype.showTwoFactorSecret = function (fCallback)
{
this.defaultRequest(fCallback, 'ShowTwoFactorSecret');
};
/**
* @param {?Function} fCallback
* @param {string} sCode