From 4748bb2c3faa9066228e22f34e91053d16648d18 Mon Sep 17 00:00:00 2001 From: Karan Bedi Date: Sat, 17 Feb 2018 16:23:20 +0530 Subject: [PATCH 1/3] [NEW] Document Domain property in IFrame --- packages/rocketchat-i18n/i18n/en.i18n.json | 1 + packages/rocketchat-iframe-login/iframe_client.js | 5 +++++ packages/rocketchat-iframe-login/iframe_rocketchat.js | 1 + 3 files changed, 7 insertions(+) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 9b728820ef71..8e49648a6962 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -57,6 +57,7 @@ "Accounts_Iframe_api_url": "API URL", "Accounts_iframe_enabled": "Enabled", "Accounts_iframe_url": "Iframe URL", + "Accounts_iframe_document_domain":"Document Domain", "Accounts_LoginExpiration": "Login Expiration in Days", "Accounts_ManuallyApproveNewUsers": "Manually Approve New Users", "Accounts_OAuth_Custom_Authorize_Path": "Authorize Path", diff --git a/packages/rocketchat-iframe-login/iframe_client.js b/packages/rocketchat-iframe-login/iframe_client.js index dcfa7d5d6bbf..949b88d5a27b 100644 --- a/packages/rocketchat-iframe-login/iframe_client.js +++ b/packages/rocketchat-iframe-login/iframe_client.js @@ -24,6 +24,11 @@ class IframeLogin { this.iframeUrl = RocketChat.settings.get('Accounts_iframe_url'); this.apiUrl = RocketChat.settings.get('Accounts_Iframe_api_url'); this.apiMethod = RocketChat.settings.get('Accounts_Iframe_api_method'); + this.documentDomain = RocketChat.settings.get('Accounts_iframe_document_domain'); + + if (this.documentDomain) { + window.document.domain = this.documentDomain; + } if (this.enabled === false) { return c.stop(); diff --git a/packages/rocketchat-iframe-login/iframe_rocketchat.js b/packages/rocketchat-iframe-login/iframe_rocketchat.js index c11db9da0c32..7e0ce747e878 100644 --- a/packages/rocketchat-iframe-login/iframe_rocketchat.js +++ b/packages/rocketchat-iframe-login/iframe_rocketchat.js @@ -5,6 +5,7 @@ Meteor.startup(function() { this.add('Accounts_iframe_url', '', { type: 'string', public: true }); this.add('Accounts_Iframe_api_url', '', { type: 'string', public: true }); this.add('Accounts_Iframe_api_method', 'POST', { type: 'string', public: true }); + this.add('Accounts_iframe_document_domain', '', { type: 'string', public: true }); }); }); }); From 4fda9b8f577b5e5ad5c9cd784e2c344ebac22989 Mon Sep 17 00:00:00 2001 From: Karan Bedi Date: Sat, 17 Feb 2018 16:35:01 +0530 Subject: [PATCH 2/3] Reorder setting document.domain and enable check --- packages/rocketchat-iframe-login/iframe_client.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/rocketchat-iframe-login/iframe_client.js b/packages/rocketchat-iframe-login/iframe_client.js index 949b88d5a27b..f3b08ea068d4 100644 --- a/packages/rocketchat-iframe-login/iframe_client.js +++ b/packages/rocketchat-iframe-login/iframe_client.js @@ -26,20 +26,21 @@ class IframeLogin { this.apiMethod = RocketChat.settings.get('Accounts_Iframe_api_method'); this.documentDomain = RocketChat.settings.get('Accounts_iframe_document_domain'); - if (this.documentDomain) { - window.document.domain = this.documentDomain; - } - if (this.enabled === false) { return c.stop(); } + if (this.documentDomain) { + window.document.domain = this.documentDomain; + } + if (this.enabled === true && this.iframeUrl && this.apiUrl && this.apiMethod) { c.stop(); if (!Accounts._storedLoginToken()) { this.tryLogin(() => {}); } } + }); } From b6d6b0f556657ba9d9e256d81a215b2a3389e67c Mon Sep 17 00:00:00 2001 From: kb0034 Date: Sun, 15 Apr 2018 12:42:34 +0530 Subject: [PATCH 3/3] [FIX] Document Domain setting --- packages/rocketchat-i18n/i18n/en.i18n.json | 2 +- packages/rocketchat-iframe-login/iframe_client.js | 6 ------ packages/rocketchat-iframe-login/iframe_rocketchat.js | 1 - packages/rocketchat-lib/client/lib/settings.js | 4 ++++ packages/rocketchat-lib/server/startup/settings.js | 4 ++++ 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index f2d9b5ebc892..76870756e2e1 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -67,7 +67,6 @@ "Accounts_Iframe_api_url": "API URL", "Accounts_iframe_enabled": "Enabled", "Accounts_iframe_url": "Iframe URL", - "Accounts_iframe_document_domain":"Document Domain", "Accounts_LoginExpiration": "Login Expiration in Days", "Accounts_ManuallyApproveNewUsers": "Manually Approve New Users", "Accounts_OAuth_Custom_Authorize_Path": "Authorize Path", @@ -561,6 +560,7 @@ "Do_not_display_unread_counter": "Do not display any counter of this channel", "Do_you_want_to_accept": "Do you want to accept?", "Do_you_want_to_change_to_s_question": "Do you want to change to %s?", + "Document_Domain":"Document Domain", "Domain": "Domain", "Domain_added": "domain Added", "Domain_removed": "Domain Removed", diff --git a/packages/rocketchat-iframe-login/iframe_client.js b/packages/rocketchat-iframe-login/iframe_client.js index f3b08ea068d4..dcfa7d5d6bbf 100644 --- a/packages/rocketchat-iframe-login/iframe_client.js +++ b/packages/rocketchat-iframe-login/iframe_client.js @@ -24,23 +24,17 @@ class IframeLogin { this.iframeUrl = RocketChat.settings.get('Accounts_iframe_url'); this.apiUrl = RocketChat.settings.get('Accounts_Iframe_api_url'); this.apiMethod = RocketChat.settings.get('Accounts_Iframe_api_method'); - this.documentDomain = RocketChat.settings.get('Accounts_iframe_document_domain'); if (this.enabled === false) { return c.stop(); } - if (this.documentDomain) { - window.document.domain = this.documentDomain; - } - if (this.enabled === true && this.iframeUrl && this.apiUrl && this.apiMethod) { c.stop(); if (!Accounts._storedLoginToken()) { this.tryLogin(() => {}); } } - }); } diff --git a/packages/rocketchat-iframe-login/iframe_rocketchat.js b/packages/rocketchat-iframe-login/iframe_rocketchat.js index 7e0ce747e878..c11db9da0c32 100644 --- a/packages/rocketchat-iframe-login/iframe_rocketchat.js +++ b/packages/rocketchat-iframe-login/iframe_rocketchat.js @@ -5,7 +5,6 @@ Meteor.startup(function() { this.add('Accounts_iframe_url', '', { type: 'string', public: true }); this.add('Accounts_Iframe_api_url', '', { type: 'string', public: true }); this.add('Accounts_Iframe_api_method', 'POST', { type: 'string', public: true }); - this.add('Accounts_iframe_document_domain', '', { type: 'string', public: true }); }); }); }); diff --git a/packages/rocketchat-lib/client/lib/settings.js b/packages/rocketchat-lib/client/lib/settings.js index 5614cf2b7c1e..75fc90c9e63c 100644 --- a/packages/rocketchat-lib/client/lib/settings.js +++ b/packages/rocketchat-lib/client/lib/settings.js @@ -82,6 +82,10 @@ Meteor.startup(function() { }); } }, 100); + const documentDomain = RocketChat.settings.get('Document_Domain'); + if (documentDomain) { + window.document.domain = documentDomain; + } return c.stop(); }); }); diff --git a/packages/rocketchat-lib/server/startup/settings.js b/packages/rocketchat-lib/server/startup/settings.js index 9b0904c01a34..8dd387de65c5 100644 --- a/packages/rocketchat-lib/server/startup/settings.js +++ b/packages/rocketchat-lib/server/startup/settings.js @@ -618,6 +618,10 @@ RocketChat.settings.addGroup('General', function() { type: 'string', 'public': true }); + this.add('Document_Domain', '', { + type: 'string', + 'public': true + }); this.add('Language', '', { type: 'language', 'public': true