From 2b0727f1893d20a48e5fef61323e7d92d6846bea Mon Sep 17 00:00:00 2001 From: hirad-deriv Date: Mon, 9 Dec 2024 17:09:17 +0800 Subject: [PATCH 1/3] chore: accepting cookie from OutSystems and logging users in --- src/javascript/app/pages/trade/tradepage.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/javascript/app/pages/trade/tradepage.js b/src/javascript/app/pages/trade/tradepage.js index f0fc065059a..8d12a8956a1 100644 --- a/src/javascript/app/pages/trade/tradepage.js +++ b/src/javascript/app/pages/trade/tradepage.js @@ -27,6 +27,21 @@ const TradePage = (() => { const iframe_target_origin = getAllowedLocalStorageOrigin(); const isOauthEnabled = AuthClient.isOAuth2Enabled(); + const client_accounts = Cookies.get('client.accounts'); + const active_loginid = Cookies.get('active_loginid'); + + if (client_accounts && active_loginid) { + localStorage.setItem('client.accounts', client_accounts); + localStorage.setItem('active_loginid', active_loginid); + + const domain = ".deriv.com"; + + // remove cookies after populating local storage + Cookies.remove('client.accounts', { domain, secure: true }); + Cookies.remove('active_loginid', { domain, secure: true }); + + window.location.reload(); + } BinarySocket.wait('authorize').then(() => { if (iframe_target_origin && !isOauthEnabled) { const el_iframe = document.getElementById('localstorage-sync'); From f830ef7e3d2c5bd26c27d3cac30af92bc91d5d01 Mon Sep 17 00:00:00 2001 From: hirad-deriv Date: Mon, 9 Dec 2024 17:13:42 +0800 Subject: [PATCH 2/3] chore: fixing errors of the PR --- src/javascript/app/pages/trade/tradepage.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/javascript/app/pages/trade/tradepage.js b/src/javascript/app/pages/trade/tradepage.js index 8d12a8956a1..21111f14b06 100644 --- a/src/javascript/app/pages/trade/tradepage.js +++ b/src/javascript/app/pages/trade/tradepage.js @@ -17,6 +17,7 @@ const TopUpVirtualPopup = require('../user/account/top_up_virtual/pop_up'); const State = require('../../../_common/storage').State; const getAllowedLocalStorageOrigin = require('../../../_common/url').getAllowedLocalStorageOrigin; const LoaderElement = require('../loader.jsx'); +const Cookies = require('js-cookie'); const TradePage = (() => { let events_initialized = 0; @@ -34,7 +35,7 @@ const TradePage = (() => { localStorage.setItem('client.accounts', client_accounts); localStorage.setItem('active_loginid', active_loginid); - const domain = ".deriv.com"; + const domain = '.deriv.com'; // remove cookies after populating local storage Cookies.remove('client.accounts', { domain, secure: true }); From 8d68a2d3c6b5e37748a76acaa0cc9ad10849cbfe Mon Sep 17 00:00:00 2001 From: hirad-deriv Date: Mon, 9 Dec 2024 17:16:39 +0800 Subject: [PATCH 3/3] chore: fixing PR errors --- src/javascript/app/pages/trade/tradepage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/javascript/app/pages/trade/tradepage.js b/src/javascript/app/pages/trade/tradepage.js index 21111f14b06..8e073325a1f 100644 --- a/src/javascript/app/pages/trade/tradepage.js +++ b/src/javascript/app/pages/trade/tradepage.js @@ -1,4 +1,5 @@ const Dropdown = require('@binary-com/binary-style').selectDropdown; +const Cookies = require('js-cookie'); const TradingAnalysis = require('./analysis'); const commonTrading = require('./common'); const cleanupChart = require('./charts/webtrader_chart').cleanupChart; @@ -17,7 +18,6 @@ const TopUpVirtualPopup = require('../user/account/top_up_virtual/pop_up'); const State = require('../../../_common/storage').State; const getAllowedLocalStorageOrigin = require('../../../_common/url').getAllowedLocalStorageOrigin; const LoaderElement = require('../loader.jsx'); -const Cookies = require('js-cookie'); const TradePage = (() => { let events_initialized = 0;