diff --git a/.env b/.env index 33da6f0904..2a6782ecdc 100644 --- a/.env +++ b/.env @@ -8,6 +8,7 @@ LANGUAGE_PREFERENCE_COOKIE_NAME=null LMS_BASE_URL=null LOGIN_URL=null LOGOUT_URL=null +REDIRECT_ON_TPA_UNLINKED_ACCOUNT_URL=null MARKETING_SITE_BASE_URL=null ORDER_HISTORY_URL=null REFRESH_ACCESS_TOKEN_ENDPOINT=null diff --git a/src/common-components/ThirdPartyAuthAlert.jsx b/src/common-components/ThirdPartyAuthAlert.jsx index 9ed908c4ba..118100d54b 100644 --- a/src/common-components/ThirdPartyAuthAlert.jsx +++ b/src/common-components/ThirdPartyAuthAlert.jsx @@ -12,6 +12,7 @@ const ThirdPartyAuthAlert = (props) => { const { formatMessage } = useIntl(); const { currentProvider, referrer } = props; const platformName = getConfig().SITE_NAME; + const unlinkedRedirectUrl = getConfig().REDIRECT_ON_TPA_UNLINKED_ACCOUNT_URL; let message; if (referrer === LOGIN_PAGE) { @@ -24,6 +25,10 @@ const ThirdPartyAuthAlert = (props) => { return null; } + if (unlinkedRedirectUrl) { + window.location.href = unlinkedRedirectUrl; + } + return ( <> diff --git a/src/common-components/tests/ThirdPartyAuthAlert.test.jsx b/src/common-components/tests/ThirdPartyAuthAlert.test.jsx index 435f122740..229d05c3e0 100644 --- a/src/common-components/tests/ThirdPartyAuthAlert.test.jsx +++ b/src/common-components/tests/ThirdPartyAuthAlert.test.jsx @@ -1,5 +1,6 @@ import React from 'react'; +import { mergeConfig } from '@edx/frontend-platform'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import renderer from 'react-test-renderer'; @@ -38,4 +39,16 @@ describe('ThirdPartyAuthAlert', () => { ).toJSON(); expect(tree).toMatchSnapshot(); }); + + it('should redirect on unlinked account', () => { + mergeConfig({ + REDIRECT_ON_TPA_UNLINKED_ACCOUNT_URL: 'http://example.com', + }); + renderer.create( + + + , + ); + expect(window.location.href).toEqual('http://example.com/'); + }); }); diff --git a/src/config/index.js b/src/config/index.js index 5a9992190d..fecca0e120 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -19,6 +19,7 @@ const configuration = { SEARCH_CATALOG_URL: process.env.SEARCH_CATALOG_URL || null, TOS_AND_HONOR_CODE: process.env.TOS_AND_HONOR_CODE || null, TOS_LINK: process.env.TOS_LINK || null, + REDIRECT_ON_TPA_UNLINKED_ACCOUNT_URL: process.env.REDIRECT_ON_TPA_UNLINKED_ACCOUNT_URL || null, // Base container images BANNER_IMAGE_LARGE: process.env.BANNER_IMAGE_LARGE || '', BANNER_IMAGE_MEDIUM: process.env.BANNER_IMAGE_MEDIUM || '',