snappymail/dev/Settings/User/Security.js

77 lines
2.1 KiB
JavaScript
Raw Normal View History

2014-08-21 23:08:34 +08:00
2014-09-05 06:49:03 +08:00
(function () {
2014-08-25 23:49:01 +08:00
'use strict';
2014-08-21 23:08:34 +08:00
var
2015-02-03 07:58:58 +08:00
_ = require('_'),
2014-08-25 23:49:01 +08:00
ko = require('ko'),
2014-08-25 15:10:51 +08:00
2014-09-05 06:49:03 +08:00
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
2014-08-25 15:10:51 +08:00
2015-02-19 03:52:52 +08:00
SettinsStore = require('Stores/User/Settings'),
Settings = require('Storage/Settings'),
2015-02-23 00:35:17 +08:00
Remote = require('Remote/User/Ajax')
2014-08-21 23:08:34 +08:00
;
/**
* @constructor
*/
function SecurityUserSettings()
2014-08-21 23:08:34 +08:00
{
2015-02-20 06:13:27 +08:00
this.capaAutoLogout = Settings.capa(Enums.Capa.AutoLogout);
2015-02-19 03:52:52 +08:00
this.capaTwoFactor = Settings.capa(Enums.Capa.TwoFactor);
this.autoLogout = SettinsStore.autoLogout;
this.autoLogout.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.autoLogoutOptions = ko.computed(function () {
Translator.trigger();
return [
{'id': 0, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_NEVER_OPTION_NAME')},
{'id': 5, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 5})},
{'id': 10, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 10})},
{'id': 30, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 30})},
{'id': 60, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 60})},
{'id': 60 * 2, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 2})},
{'id': 60 * 5, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 5})},
{'id': 60 * 10, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 10})}
2015-02-19 03:52:52 +08:00
];
});
2014-08-21 23:08:34 +08:00
}
SecurityUserSettings.prototype.configureTwoFactor = function ()
2014-08-21 23:08:34 +08:00
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/TwoFactorConfiguration'));
2014-08-21 23:08:34 +08:00
};
SecurityUserSettings.prototype.onBuild = function ()
2014-08-21 23:08:34 +08:00
{
2015-02-20 06:13:27 +08:00
if (this.capaAutoLogout)
{
var self = this;
2015-02-19 03:52:52 +08:00
2015-02-20 06:13:27 +08:00
_.delay(function () {
2015-02-19 03:52:52 +08:00
2015-02-20 06:13:27 +08:00
var
f0 = Utils.settingsSaveHelperSimpleFunction(self.autoLogout.trigger, self)
;
2015-02-19 03:52:52 +08:00
2015-02-20 06:13:27 +08:00
self.autoLogout.subscribe(function (sValue) {
Remote.saveSettings(f0, {
'AutoLogout': Utils.pInt(sValue)
});
2015-02-19 03:52:52 +08:00
});
2015-02-20 06:13:27 +08:00
});
}
2014-08-21 23:08:34 +08:00
};
module.exports = SecurityUserSettings;
2014-08-21 23:08:34 +08:00
2016-06-28 04:54:38 +08:00
}());