Skip to content

Commit

Permalink
go back to previous url after session expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
AshrafMd-1 committed Oct 25, 2023
1 parent 438dc61 commit a838ca7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Components/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ export const Login = (props: { forgot?: boolean }) => {
window.location.pathname === "/" ||
window.location.pathname === "/login"
) {
window.location.href = "/facility";
const lastPath = localStorage.getItem("lastPath");
if (lastPath) {
localStorage.removeItem("lastPath");
window.location.href = lastPath;
} else {
window.location.href = "/facility";
}
} else {
window.location.href = window.location.pathname.toString();
}
Expand Down
2 changes: 2 additions & 0 deletions src/Redux/fireRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ export const fireRequest = (
if (error.response.status > 400 && error.response.status < 500) {
if (error.response.data && error.response.data.detail) {
if (error.response.data.code === "token_not_valid") {
//store the path before session expiry in local storage
localStorage.setItem("lastPath", window.location.href);
window.location.href = "/session-expired";
}
Notification.Error({
Expand Down

0 comments on commit a838ca7

Please sign in to comment.