Skip to content

Commit

Permalink
Navigate to session expired page instead of showing notification (#8363)
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Sep 3, 2024
1 parent 87b0123 commit c471332
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/Utils/request/handleResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ export default function handleResponse(

// Other Errors between 400-599 (inclusive)
if (res.status >= 400 && res.status < 600) {
// Invalid token
if (!silent && error?.code === "token_not_valid") {
navigate(`/session-expired?redirect=${window.location.href}`);
}

// Handle session expiry
if (error?.detail === "Authentication credentials were not provided.") {
notify?.Error({ msg: "Session expired. Please Login again." });
// Handle invalid token / session expiry
if (
!silent &&
(error?.code === "token_not_valid" ||
error?.detail === "Authentication credentials were not provided.")
) {
if (!location.pathname.startsWith("/session-expired")) {
navigate(`/session-expired?redirect=${window.location.href}`);
}
return;
}

Expand Down

0 comments on commit c471332

Please sign in to comment.