diff --git a/frontend/packages/shared/src/contexts/ServicesContext.tsx b/frontend/packages/shared/src/contexts/ServicesContext.tsx index 36653519d78..342c593b8bc 100644 --- a/frontend/packages/shared/src/contexts/ServicesContext.tsx +++ b/frontend/packages/shared/src/contexts/ServicesContext.tsx @@ -55,12 +55,15 @@ const handleError = ( const errorCode = error?.response?.data?.errorCode; const unAuthorizedErrorCode = error?.response?.status === ServerCodes.Unauthorized; + const LogOutUser = () => logout().then(() => window.location.assign(userLogoutAfterPath())); + if (unAuthorizedErrorCode) { renderToast(errorCode || 'Unauthorized', { + onClose: LogOutUser, autoClose: LOG_OUT_TIMER_MS, }); setTimeout(() => { - logout().then(() => window.location.assign(userLogoutAfterPath())); + LogOutUser(); }, LOG_OUT_TIMER_MS); return; }