From 662605084208606c167bee6567e2d2cb88c6ec3a Mon Sep 17 00:00:00 2001 From: Caleb Cox Date: Thu, 31 Oct 2024 13:36:44 -0500 Subject: [PATCH] Redirect after login --- pages/login.page.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pages/login.page.tsx b/pages/login.page.tsx index 4fa97213c..800830712 100644 --- a/pages/login.page.tsx +++ b/pages/login.page.tsx @@ -11,6 +11,7 @@ import Welcome from 'src/components/Welcome'; import useGetAppSettings from 'src/hooks/useGetAppSettings'; import { extractCookie } from 'src/lib/extractCookie'; import i18n from 'src/lib/i18n'; +import { getQueryParam } from 'src/utils/queryParam'; const SignUpBox = styled('div')(({ theme }) => ({ marginBlock: theme.spacing(2), @@ -124,10 +125,11 @@ export const getServerSideProps: GetServerSideProps = async (context) => { `mpdx-handoff.redirect-url=; HttpOnly; path=/; Max-Age=0`, ); } - if (context.res && session && !impersonateCookie) { + if (session && !impersonateCookie) { + const queryRedirectUrl = getQueryParam(context.query, 'redirect'); return { redirect: { - destination: redirectCookie ?? '/accountLists', + destination: redirectCookie ?? queryRedirectUrl ?? '/accountLists', permanent: false, }, };