Added auto logout option

This commit is contained in:
RainLoop Team 2015-02-18 23:52:52 +04:00
parent 76f319a07f
commit bb551e4ec8
18 changed files with 171 additions and 33 deletions

View file

@ -92,6 +92,10 @@
Globals.$html.removeClass('rl-ctrl-key-pressed');
}
});
Globals.$doc.on('mousemove keypress click', _.debounce(function () {
Events.pub('rl.auto-logout-refresh');
}, 5000));
}
_.extend(AbstractApp.prototype, AbstractBoot.prototype);

View file

@ -1398,6 +1398,15 @@
});
};
AppUser.prototype.logout = function ()
{
var self = this;
Remote.logout(function () {
self.loginAndLogoutReload(true,
Settings.settingsGet('ParentEmail') && 0 < Settings.settingsGet('ParentEmail').length);
});
};
AppUser.prototype.bootstartLoginScreen = function ()
{
Globals.$html.removeClass('rl-user-auth').addClass('rl-user-no-auth');
@ -1568,6 +1577,10 @@
Remote.appDelayStart(Utils.emptyFunction);
}, 35000);
Events.sub('rl.auto-logout', function () {
self.logout();
});
Plugins.runHook('rl-start-user-screens');
Events.pub('rl.bootstart-user-screens');

View file

@ -263,7 +263,8 @@
Enums.Layout = {
'NoPreview': 0,
'SidePreview': 1,
'BottomPreview': 2
'BottomPreview': 2,
'Mobile': 3
};
/**

View file

@ -63,11 +63,8 @@
'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters');
}
if (Settings.capa(Enums.Capa.TwoFactor))
{
kn.addSettingsViewModel(require('Settings/User/Security'),
'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security');
}
kn.addSettingsViewModel(require('Settings/User/Security'),
'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security');
if ((Settings.settingsGet('AllowGoogleSocial') && Settings.settingsGet('AllowGoogleSocialAuth')) ||
Settings.settingsGet('AllowFacebookSocial') ||

View file

@ -11,6 +11,10 @@
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
SettinsStore = require('Stores/User/Settings'),
Settings = require('Storage/Settings'),
Remote = require('Storage/User/Remote')
;
@ -19,6 +23,22 @@
*/
function SecurityUserSettings()
{
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})}
];
});
this.processing = ko.observable(false);
this.clearing = ko.observable(false);
this.secreting = ko.observable(false);
@ -186,8 +206,27 @@
SecurityUserSettings.prototype.onBuild = function ()
{
this.processing(true);
Remote.getTwoFactor(this.onResult);
if (this.capaTwoFactor)
{
this.processing(true);
Remote.getTwoFactor(this.onResult);
}
var self = this;
_.delay(function () {
var
f0 = Utils.settingsSaveHelperSimpleFunction(self.autoLogout.trigger, self)
;
self.autoLogout.subscribe(function (sValue) {
Remote.saveSettings(f0, {
'AutoLogout': Utils.pInt(sValue)
});
});
});
};
module.exports = SecurityUserSettings;

View file

@ -24,6 +24,11 @@
this.accounts = ko.observableArray([]);
this.accounts.loading = ko.observable(false).extend({'throttle': 100});
this.computers();
}
AccountUserStore.prototype.computers = function ()
{
this.accountsEmails = ko.computed(function () {
return _.compact(_.map(this.accounts(), function (oItem) {
return oItem ? oItem.email : null;
@ -44,7 +49,7 @@
return iResult;
}, this);
}
};
AccountUserStore.prototype.populate = function ()
{

View file

@ -23,18 +23,18 @@
this.trashFolder = ko.observable('');
this.archiveFolder = ko.observable('');
this.computed();
this.subscribe();
this.computers();
this.subscribers();
}
FolderUserStore.prototype.computed = function ()
FolderUserStore.prototype.computers = function ()
{
this.draftFolderNotEnabled = ko.computed(function () {
return '' === this.draftFolder() || Consts.Values.UnuseOptionValue === this.draftFolder();
}, this);
};
FolderUserStore.prototype.subscribe = function ()
FolderUserStore.prototype.subscribers = function ()
{
var
fRemoveSystemFolderType = function (observable) {

View file

@ -126,12 +126,12 @@
};
}
this.computedProperies();
this.computers();
this.initNotificationPlayer();
}
NotificationUserStore.prototype.computedProperies = function ()
NotificationUserStore.prototype.computers = function ()
{
this.isDesktopNotificationSupported = ko.computed(function () {
return Enums.DesktopNotification.NotSupported !== this.desktopNotificationPermissions();

View file

@ -4,6 +4,7 @@
'use strict';
var
window = require('window'),
ko = require('ko'),
Consts = require('Common/Consts'),
@ -20,6 +21,8 @@
*/
function SettingsUserStore()
{
this.iAutoLogoutTimer = 0;
this.layout = ko.observable(Enums.Layout.SidePreview)
.extend({'limitedList': [
Enums.Layout.SidePreview, Enums.Layout.BottomPreview, Enums.Layout.NoPreview
@ -39,24 +42,27 @@
this.useThreads = ko.observable(false);
this.replySameFolder = ko.observable(false);
this.computedProperies();
this.subscribes();
this.autoLogout = ko.observable(30);
this.computers();
this.subscribers();
}
SettingsUserStore.prototype.computedProperies = function ()
SettingsUserStore.prototype.computers = function ()
{
this.usePreviewPane = ko.computed(function () {
return Enums.Layout.NoPreview !== this.layout();
}, this);
};
SettingsUserStore.prototype.subscribes = function ()
SettingsUserStore.prototype.subscribers = function ()
{
this.layout.subscribe(function (nValue) {
Globals.$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === nValue);
Globals.$html.toggleClass('rl-side-preview-pane', Enums.Layout.SidePreview === nValue);
Globals.$html.toggleClass('rl-bottom-preview-pane', Enums.Layout.BottomPreview === nValue);
Globals.$html.toggleClass('rl-mobile-layout', Enums.Layout.Mobile === nValue);
Events.pub('layout', [nValue]);
});
@ -67,12 +73,27 @@
this.layout(Utils.pInt(Settings.settingsGet('Layout')));
this.editorDefaultType(Settings.settingsGet('EditorDefaultType'));
this.autoLogout(Utils.pInt(Settings.settingsGet('AutoLogout')));
this.messagesPerPage(Settings.settingsGet('MPP'));
this.showImages(!!Settings.settingsGet('ShowImages'));
this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList'));
this.useThreads(!!Settings.settingsGet('UseThreads'));
this.replySameFolder(!!Settings.settingsGet('ReplySameFolder'));
var self = this;
Events.sub('rl.auto-logout-refresh', function () {
window.clearTimeout(self.iAutoLogoutTimer);
if (0 < self.autoLogout())
{
self.iAutoLogoutTimer = window.setTimeout(function () {
Events.pub('rl.auto-logout');
}, self.autoLogout() * 1000 * 60);
}
});
Events.pub('rl.auto-logout-refresh');
};
module.exports = new SettingsUserStore();

View file

@ -21,6 +21,11 @@
this.templatesNames = ko.observableArray([]).extend({'throttle': 1000});
this.templatesNames.skipFirst = true;
this.subscribers();
}
TemplateUserStore.prototype.subscribers = function ()
{
this.templates.subscribe(function (aList) {
this.templatesNames(_.compact(_.map(aList, function (oItem) {
return oItem ? oItem.name : null;
@ -37,7 +42,7 @@
// Remote.templatesSortOrder(null, aList);
// }
// }, this);
}
};
module.exports = new TemplateUserStore();

View file

@ -36,6 +36,11 @@
line-height: 22px;
}
.identity-default {
cursor: pointer;
color: #ccc;
}
.identity-name {
display: inline-block;
word-break: break-all;

View file

@ -1321,7 +1321,7 @@
return false;
});
if (!!Settings.settingsGet('AllowСtrlEnterOnCompose'))
if (!!Settings.settingsGet('AllowCtrlEnterOnCompose'))
{
key('ctrl+enter, command+enter', Enums.KeyState.Compose, function () {
self.sendCommand();

View file

@ -15,7 +15,6 @@
AccountStore = require('Stores/User/Account'),
Settings = require('Storage/Settings'),
Remote = require('Storage/User/Remote'),
AbstractView = require('Knoin/AbstractView')
;
@ -80,10 +79,7 @@
AbstractSystemDropDownUserView.prototype.logoutClick = function ()
{
Remote.logout(function () {
require('App/User').loginAndLogoutReload(true,
Settings.settingsGet('ParentEmail') && 0 < Settings.settingsGet('ParentEmail').length);
});
require('App/User').logout();
};
AbstractSystemDropDownUserView.prototype.onBuild = function ()