Skip to content

Commit

Permalink
Merge pull request #5543 from guardian/gh-lp-query-params-newspaper
Browse files Browse the repository at this point in the history
Changes to Keep query parameters in URL when signing out for Newspaper
  • Loading branch information
LAKSHMIRPILLAI authored Apr 22, 2024
2 parents a48ca3f + 69ff0d2 commit a816124
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as storage from 'helpers/storage/storage';

const REDIRECT_AFTER_SIGNOUT_STORAGE_KEY = 'redirectAfterSignOut';

export const setSignOutRedirectInStorage = (): void => {
storage.setSession(REDIRECT_AFTER_SIGNOUT_STORAGE_KEY, window.location.href);
};

export const checkSignOutRedirectInStorage = (): void => {
const redirectUrlFromSessionStorage = storage.getSession(
REDIRECT_AFTER_SIGNOUT_STORAGE_KEY,
);
//This check is to make sure we are retaining the url with query params when we hit sign out
if (redirectUrlFromSessionStorage) {
storage.setSession(REDIRECT_AFTER_SIGNOUT_STORAGE_KEY, '');
window.location.href = redirectUrlFromSessionStorage;
}
};
2 changes: 2 additions & 0 deletions support-frontend/assets/helpers/user/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getGlobal, isSwitchOn } from 'helpers/globalsAndSwitches/globals';
import * as cookie from 'helpers/storage/cookie';
import type { Option } from 'helpers/types/option';
import { getSignoutUrl } from 'helpers/urls/externalLinks';
import { setSignOutRedirectInStorage } from '../signoutRedirectStorage/signoutRedirectStorage';

export type User = {
firstName: Option<string>;
Expand Down Expand Up @@ -50,6 +51,7 @@ const isPostDeployUser = (): boolean =>
cookie.get('_post_deploy_user') === 'true';

const signOut = (): void => {
setSignOutRedirectInStorage();
window.location.href = getSignoutUrl();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ import {
getProductOption,
getStartDate,
} from 'pages/paper-subscription-checkout/helpers/options';
import { checkSignOutRedirectInStorage } from '../../helpers/signoutRedirectStorage/signoutRedirectStorage';
import ThankYouContent from './components/thankYou';
import 'stylesheets/skeleton/skeleton.scss';
import './_legacyImports.scss';

checkSignOutRedirectInStorage();
setUpTrackingAndConsents();
// ----- Redux Store ----- //
const fulfilmentOption = getFulfilmentOption();
Expand Down

0 comments on commit a816124

Please sign in to comment.