File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
packages/webapp/components Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import type { ReactElement, ReactNode } from 'react';
22import React , { useContext , useEffect } from 'react' ;
33import { useRouter } from 'next/router' ;
44import AuthContext from '@dailydotdev/shared/src/contexts/AuthContext' ;
5+ import { AFTER_AUTH_PARAM } from '@dailydotdev/shared/src/components/auth/common' ;
56
67export interface ProtectedPageProps {
78 children : ReactNode ;
@@ -19,7 +20,12 @@ function ProtectedPage({
1920
2021 useEffect ( ( ) => {
2122 if ( tokenRefreshed && ! user ) {
22- router . replace ( '/' ) ;
23+ const params = new URLSearchParams ( window . location . search ) ;
24+ if ( ! params . get ( AFTER_AUTH_PARAM ) ) {
25+ params . set ( AFTER_AUTH_PARAM , window . location . pathname ) ;
26+ }
27+ const redirectUrl = params . toString ( ) ? `/?${ params . toString ( ) } ` : '/' ;
28+ router . replace ( redirectUrl ) ;
2329 }
2430 // @NOTE see https://dailydotdev.atlassian.net/l/cp/dK9h1zoM
2531 // eslint-disable-next-line react-hooks/exhaustive-deps
You can’t perform that action at this time.
0 commit comments