From c47133200fcdb63458d722c5b0618660d1b50e81 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Tue, 3 Sep 2024 15:03:48 +0530 Subject: [PATCH] Navigate to session expired page instead of showing notification (#8363) --- src/Utils/request/handleResponse.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Utils/request/handleResponse.ts b/src/Utils/request/handleResponse.ts index 9f85b50a68d..905417ad0e2 100644 --- a/src/Utils/request/handleResponse.ts +++ b/src/Utils/request/handleResponse.ts @@ -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; }