From adca9029ae6ceeb96b7edf05605f6fd0ad92cf08 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Tue, 2 May 2023 09:02:09 +0100 Subject: [PATCH] made loading profile to load only when user login status is false --- src/middleware/AuthRoute.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/middleware/AuthRoute.jsx b/src/middleware/AuthRoute.jsx index 1dee9d9..f57ec6e 100644 --- a/src/middleware/AuthRoute.jsx +++ b/src/middleware/AuthRoute.jsx @@ -34,6 +34,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { window.addEventListener('keydown', resetTime) const loadProfile = ()=>{ // function to load user profile + setIsLogin({loading: true, status: false}) apiCall.loadProfile().then((res)=>{ if(res.data.internal_return < 0){ setIsLogin({loading: false, status: false}) @@ -50,7 +51,9 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { }, []) useEffect(() => { - getProfile() + if(!isLogin.status){ + getProfile() + } const checkInactivity = setInterval(() => { if (Date.now() - lastActivityTime > process.env.REACT_APP_SESSION_EXPIRE_MINUTES) {