diff --git a/frontend/src/AppRoutes/Private.tsx b/frontend/src/AppRoutes/Private.tsx index 669def6f44..43402fdbb2 100644 --- a/frontend/src/AppRoutes/Private.tsx +++ b/frontend/src/AppRoutes/Private.tsx @@ -76,9 +76,8 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element { isUserFetching: false, }, }); - if (!isLoggedIn) { - history.push(ROUTES.LOGIN); + history.push(ROUTES.LOGIN, { from: pathname }); } }; diff --git a/frontend/src/container/Login/index.tsx b/frontend/src/container/Login/index.tsx index df9a1c6a37..81a6c535a5 100644 --- a/frontend/src/container/Login/index.tsx +++ b/frontend/src/container/Login/index.tsx @@ -163,8 +163,15 @@ function Login({ response.payload.accessJwt, response.payload.refreshJwt, ); + if (history?.location?.state) { + const historyState = history?.location?.state as any; - history.push(ROUTES.APPLICATION); + if (historyState?.from) { + history.push(historyState?.from); + } else { + history.push(ROUTES.APPLICATION); + } + } } else { notifications.error({ message: response.error || t('unexpected_error'),