From 648aa95fbf7da9ee45ece8f1e284ed7d6f9023dc Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento <rodrigoknascimento@gmail.com> Date: Tue, 1 Nov 2016 18:49:46 -0200 Subject: [PATCH] Add setting to Forget user session on window close --- packages/rocketchat-i18n/i18n/en.i18n.json | 3 ++- .../server/startup/settings.coffee | 1 + .../rocketchat-ui-master/server/inject.js | 20 +++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index a053a21c603..ced16b42917 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -41,6 +41,7 @@ "Accounts_Enrollment_Email_Default": "<h2>Welcome to <h1>[Site_Name]</h1></h2><p>Go to [Site_URL] and try the best open source chat solution available today!</p>", "Accounts_Enrollment_Email_Description": "You may use the following placeholders: <br /><ul><li>[name], [fname], [lname] for the user's full name, first name or last name, respectively.</li><li>[email] for the user's email.</li><li>[Site_Name] and [Site_URL] for the Application Name and URL respectively.</li></ul>", "Accounts_Enrollment_Email_Subject_Default": "Welcome to [Site_Name]", + "Accounts_ForgetUserSessionOnWindowClose": "Forget user session on window close", "Accounts_Iframe_api_method": "Api Method", "Accounts_Iframe_api_url": "API URL", "Accounts_iframe_enabled": "Enabled", @@ -1458,4 +1459,4 @@ "your_message_optional": "your message (optional)", "Your_password_is_wrong": "Your password is wrong!", "Your_push_was_sent_to_s_devices": "Your push was sent to %s devices" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/server/startup/settings.coffee b/packages/rocketchat-lib/server/startup/settings.coffee index 201ead812b3..0481211e144 100644 --- a/packages/rocketchat-lib/server/startup/settings.coffee +++ b/packages/rocketchat-lib/server/startup/settings.coffee @@ -14,6 +14,7 @@ RocketChat.settings.addGroup 'Accounts', -> @add 'Accounts_ShowFormLogin', true, { type: 'boolean', public: true } @add 'Accounts_EmailOrUsernamePlaceholder', '', { type: 'string', public: true, i18nLabel: 'Placeholder_for_email_or_username_login_field' } @add 'Accounts_PasswordPlaceholder', '', { type: 'string', public: true, i18nLabel: 'Placeholder_for_password_login_field' } + @add 'Accounts_ForgetUserSessionOnWindowClose', false, { type: 'boolean', public: true } @section 'Registration', -> @add 'Accounts_RequireNameForSignUp', true, { type: 'boolean', public: true } diff --git a/packages/rocketchat-ui-master/server/inject.js b/packages/rocketchat-ui-master/server/inject.js index 760045e3650..10cabc9a764 100644 --- a/packages/rocketchat-ui-master/server/inject.js +++ b/packages/rocketchat-ui-master/server/inject.js @@ -64,6 +64,26 @@ RocketChat.settings.get('theme-color-tertiary-background-color', function(key, v } }); +RocketChat.settings.get('Accounts_ForgetUserSessionOnWindowClose', function(key, value) { + if (value) { + console.log('Accounts_ForgetUserSessionOnWindowClose'); + Inject.rawModHtml('Accounts_ForgetUserSessionOnWindowClose', function(html) { + const script = ` + <script> + if (Meteor._localStorage._data === undefined && window.sessionStorage) { + Meteor._localStorage = window.sessionStorage; + } + </script> + `; + return html.replace(/<\/body>/, script+'\n</body>'); + }); + } else { + Inject.rawModHtml('Accounts_ForgetUserSessionOnWindowClose', function(html) { + return html; + }); + } +}); + RocketChat.settings.get('Site_Url', function() { Meteor.defer(function() { let baseUrl; -- GitLab