diff --git a/.ci/config-test.inc.php b/.ci/config-test.inc.php index 1432b7d142..1206ddffad 100644 --- a/.ci/config-test.inc.php +++ b/.ci/config-test.inc.php @@ -35,6 +35,7 @@ 'attachment_reminder', 'markasjunk', 'zipdownload', + 'persisted_login', ]; $config['archive_mbox'] = 'Archive'; diff --git a/.tx/config b/.tx/config index e86eabe63a..c2b05bbc8f 100644 --- a/.tx/config +++ b/.tx/config @@ -72,6 +72,11 @@ file_filter = plugins/password/localization/.inc source_file = plugins/password/localization/en_US.inc source_lang = en_US +[o:roundcube:p:roundcube-webmail:r:plugin-persisted-login] +file_filter = plugins/persisted_login/localization/.inc +source_file = plugins/persisted_login/localization/en_US.inc +source_lang = en_US + [o:roundcube:p:roundcube-webmail:r:plugin-subscriptions_option] file_filter = plugins/subscriptions_option/localization/.inc source_file = plugins/subscriptions_option/localization/en_US.inc @@ -96,4 +101,3 @@ source_lang = en_US file_filter = program/localization//timezones.inc source_file = program/localization/en_US/timezones.inc source_lang = en_US - diff --git a/plugins/persisted_login/README.md b/plugins/persisted_login/README.md new file mode 100644 index 0000000000..4311a5252d --- /dev/null +++ b/plugins/persisted_login/README.md @@ -0,0 +1,26 @@ +Persisted login Roundcubemail plugin +==================================== + +This plugin adds a toggle switch into the login form of Roundcubemail's "elastic" skin, that makes the session live for a configured number of days (instead of only for the session). + +In effect, logins stay valid across network changes of clients, etc. + +From a technical point of view this plugin (if enabled) overrides `$config['session_lifetime']` (which sets the session garbage collection max lifetime in PHP) to match the number of days set in its own config. + +Usage +----- + +Enable the plugin in your Roundcubemail's config: + +```php +$config['plugins'] = [ …, 'persisted_login']; +``` + +By default logins are persisted for 7 days. That value can be changed via the config option `persisted_login_days` in the +config file of this plugin. (Make sure that the config file ends in `.php` to have it used by Roundcubemail.) + + +Credits +------- + +Most of this code was actually written by [Github-Citizen](https://github.com/Github-Citizen) for https://github.com/roundcube/roundcubemail/pull/8689, which fell through due to styling issues, and only cleaned up and renamed for this plugin. diff --git a/plugins/persisted_login/config.inc.php.dist b/plugins/persisted_login/config.inc.php.dist new file mode 100644 index 0000000000..2e3317b835 --- /dev/null +++ b/plugins/persisted_login/config.inc.php.dist @@ -0,0 +1,17 @@ + { + const days = rcmail.env.persisted_login_days; + let txt = rcmail.gettext('switch_text', 'persisted_login'); + txt = txt.replace('#', days); + + const elems = $('').addClass('form-group row').append( + $('').addClass('title').hide(), + $('').addClass('input input-group input-group-lg').append( + $('
').addClass('custom-control custom-switch').css('padding', '1em 0').append( + $('').attr({ + type: 'checkbox', + class: 'custom-control-input', + id: '_persisted_login', + name: '_persisted_login', + value: '1', + }), + $('