feat: redirect to original page after login (#5604)

This commit is contained in:
rahulkeswani101 2024-08-01 08:49:26 +05:30 committed by GitHub
parent fff9954da2
commit ae19eaa76a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -76,9 +76,8 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element {
isUserFetching: false, isUserFetching: false,
}, },
}); });
if (!isLoggedIn) { if (!isLoggedIn) {
history.push(ROUTES.LOGIN); history.push(ROUTES.LOGIN, { from: pathname });
} }
}; };

View File

@ -163,8 +163,15 @@ function Login({
response.payload.accessJwt, response.payload.accessJwt,
response.payload.refreshJwt, 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 { } else {
notifications.error({ notifications.error({
message: response.error || t('unexpected_error'), message: response.error || t('unexpected_error'),