From fd434d1b0b5b3eb4424ee1a7762edd7708832684 Mon Sep 17 00:00:00 2001 From: Sundaram Kumar Jha <93595231+sundaram2021@users.noreply.github.com> Date: Tue, 14 Feb 2023 17:11:33 +0530 Subject: [PATCH] modified Dashboard.js There should be an storage event becuase while hovering over dashboard if user some how deleted local storage or history of the page then the user should login again to get the token in local storage --- client/src/pages/Dashboard.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/src/pages/Dashboard.js b/client/src/pages/Dashboard.js index 41240b8..0265961 100644 --- a/client/src/pages/Dashboard.js +++ b/client/src/pages/Dashboard.js @@ -57,6 +57,12 @@ const Dashboard = () => { alert(data.error) } } + + window.addEventListener("storage", function (event) { + if (event.key === "token" && !event.newValue) { + window.location.replace("/login"); + } + }); return (