fix(ui): jwt redirect

This commit is contained in:
Shekar Siri 2023-08-18 17:45:32 +05:30
parent c8f4c0e780
commit be8430fe5b

View file

@ -132,13 +132,9 @@ class Router extends React.Component {
};
componentDidMount() {
const { isLoggedIn, location } = this.props;
const destinationPath = localStorage.getItem(GLOBAL_DESTINATION_PATH);
if (!isLoggedIn && !location.pathname.includes('login')) {
const { location } = this.props;
if (!location.pathname.includes('login')) {
localStorage.setItem(GLOBAL_DESTINATION_PATH, location.pathname);
} else if (isLoggedIn && destinationPath && !location.pathname.includes(destinationPath)) {
this.props.history.push(destinationPath || '/');
localStorage.removeItem(GLOBAL_DESTINATION_PATH);
}
}
@ -162,6 +158,7 @@ class Router extends React.Component {
if (!prevProps.isLoggedIn && this.props.isLoggedIn) {
this.fetchInitialData();
localStorage.removeItem(GLOBAL_DESTINATION_PATH);
}
}