From cf5d15239e6fcbf799f575bf14610f2b38d816bf Mon Sep 17 00:00:00 2001 From: adrienne-deriv <103016120+adrienne-deriv@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:52:25 +0800 Subject: [PATCH] Adrienne / Read query params and store them for oidc (#17991) * chore: read query params and store them for oidc * chore: remove local storage setter for tokens --- packages/core/src/Stores/client-store.js | 15 +++++++++++++++ packages/hooks/src/useSilentLoginAndLogout.ts | 7 ------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/core/src/Stores/client-store.js b/packages/core/src/Stores/client-store.js index ef59710ff4a9..ca9264019f9c 100644 --- a/packages/core/src/Stores/client-store.js +++ b/packages/core/src/Stores/client-store.js @@ -1545,6 +1545,21 @@ export default class ClientStore extends BaseStore { if (search) { if (window.location.pathname !== routes.callback_page) { if (code_param && action_param) this.setVerificationCode(code_param, action_param); + // NOTE: Remove this logic once social signup is intergated with OIDC + const params = new URLSearchParams(window.location.search); + const isUsingLegacyFlow = params.has('token1') && params.has('acct1'); + const loggedState = Cookies.get('logged_state'); + + if (isUsingLegacyFlow && loggedState === 'false') { + const currentDomain = window.location.hostname.split('.').slice(-2).join('.'); + Cookies.set('logged_state', 'true', { + expires: 30, + path: '/', + domain: currentDomain, + secure: true, + }); + } + document.addEventListener('DOMContentLoaded', () => { setTimeout(() => { // timeout is needed to get the token (code) from the URL before we hide it from the URL diff --git a/packages/hooks/src/useSilentLoginAndLogout.ts b/packages/hooks/src/useSilentLoginAndLogout.ts index 18f1d03a3737..284a007578cc 100644 --- a/packages/hooks/src/useSilentLoginAndLogout.ts +++ b/packages/hooks/src/useSilentLoginAndLogout.ts @@ -33,13 +33,6 @@ const useSilentLoginAndLogout = ({ const params = new URLSearchParams(window.location.search); const isUsingLegacyFlow = params.has('token1') && params.has('acct1'); if (isUsingLegacyFlow && loggedState === 'false' && isOAuth2Enabled) { - const currentDomain = window.location.hostname.split('.').slice(-2).join('.'); - Cookies.set('logged_state', 'true', { - expires: 30, - path: '/', - domain: currentDomain, - secure: true, - }); return; }