From 9a30f053c7f92f797e73c6ab41cb44ebc2e4a632 Mon Sep 17 00:00:00 2001 From: Mubbshar Anwar <78487564+mubbsharanwar@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:57:18 +0500 Subject: [PATCH] fix: fix marketingEmailsOptIn null value (#1294) Fix marketingEmailsOptIn null value issue for SSO flow on onboarding component VAN-2013 --- src/common-components/ThirdPartyAuthAlert.jsx | 6 +++++- src/login/LoginPage.jsx | 4 ++++ src/register/RegistrationPage.jsx | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/common-components/ThirdPartyAuthAlert.jsx b/src/common-components/ThirdPartyAuthAlert.jsx index fb79a6a6..fa2c6ee6 100644 --- a/src/common-components/ThirdPartyAuthAlert.jsx +++ b/src/common-components/ThirdPartyAuthAlert.jsx @@ -7,6 +7,7 @@ import PropTypes from 'prop-types'; import messages from './messages'; import { LOGIN_PAGE, REGISTER_PAGE } from '../data/constants'; +import setCookie from '../data/utils/cookies'; const ThirdPartyAuthAlert = (props) => { const { formatMessage } = useIntl(); @@ -20,7 +21,10 @@ const ThirdPartyAuthAlert = (props) => { message = formatMessage(messages['register.third.party.auth.account.not.linked'], { currentProvider, platformName }); } - if (!currentProvider) { + if (currentProvider) { + // Setting this cookie to capture marketingEmailsOptIn for SSO flow on the onboarding component + setCookie('ssoPipelineRedirectionDone', true); + } else { return null; } diff --git a/src/login/LoginPage.jsx b/src/login/LoginPage.jsx index 0ff25258..6a935935 100644 --- a/src/login/LoginPage.jsx +++ b/src/login/LoginPage.jsx @@ -41,6 +41,7 @@ import { getTpaProvider, updatePathWithQueryParams, } from '../data/utils'; +import { removeCookie } from '../data/utils/cookies'; import ResetPasswordSuccess from '../reset-password/ResetPasswordSuccess'; import { trackForgotPasswordLinkClick, trackLoginPageViewed, trackLoginSuccess, @@ -86,6 +87,9 @@ const LoginPage = (props) => { useEffect(() => { if (loginResult.success) { trackLoginSuccess(); + + // Remove this cookie that was set to capture marketingEmailsOptIn for the onboarding component + removeCookie('ssoPipelineRedirectionDone'); } }, [loginResult]); diff --git a/src/register/RegistrationPage.jsx b/src/register/RegistrationPage.jsx index 50f689bf..8b6dc9fd 100644 --- a/src/register/RegistrationPage.jsx +++ b/src/register/RegistrationPage.jsx @@ -188,8 +188,10 @@ const RegistrationPage = (props) => { // This is used by the "User Retention Rate Event" on GTM setCookie(getConfig().USER_RETENTION_COOKIE_NAME, true); - // remove marketingEmailsOptIn cookie that was set on SSO registration flow + // Remove marketingEmailsOptIn cookie that was set on SSO registration flow removeCookie('marketingEmailsOptIn'); + // Remove this cookie that was set to capture marketingEmailsOptIn for the onboarding component + removeCookie('ssoPipelineRedirectionDone'); } }, [registrationResult]);