diff --git a/src/fireedge/src/client/components/HOC/MainLayout.js b/src/fireedge/src/client/components/HOC/MainLayout.js index cb81267aee..6cf2b354db 100644 --- a/src/fireedge/src/client/components/HOC/MainLayout.js +++ b/src/fireedge/src/client/components/HOC/MainLayout.js @@ -39,14 +39,16 @@ const MainLayout = ({ endpoints, children }) => { isLoginInProcess, getAuthInfo, authUser, - firstRender + firstRender, + isLoading } = useAuth() useEffect(() => { - if (isLogged && !isLoginInProcess) { + console.log({ isLoading }) + if (isLogged && !isLoginInProcess && !isLoading) { getAuthInfo() } - }, [isLogged, isLoginInProcess]) + }, [isLogged, isLoginInProcess, pathname]) const { authenticated } = findRouteByPathname(ENDPOINTS, pathname) const authRoute = Boolean(authenticated) diff --git a/src/fireedge/src/client/components/Sidebar/index.js b/src/fireedge/src/client/components/Sidebar/index.js index 92f459347a..1423aeee18 100644 --- a/src/fireedge/src/client/components/Sidebar/index.js +++ b/src/fireedge/src/client/components/Sidebar/index.js @@ -85,7 +85,7 @@ const Sidebar = memo(({ endpoints }) => { ) -}, (prev, next) => prev.endpoints === next.endpoints) +}, (prev, next) => prev.endpoints.length === next.endpoints.length) Sidebar.propTypes = { endpoints: PropTypes.array diff --git a/src/fireedge/src/client/constants/translates.js b/src/fireedge/src/client/constants/translates.js index 393d35aeb2..dcf198c38e 100644 --- a/src/fireedge/src/client/constants/translates.js +++ b/src/fireedge/src/client/constants/translates.js @@ -35,6 +35,7 @@ module.exports = { Token2FA: '2FA Token', KeepLoggedIn: 'Keep me logged in', Credentials: 'Credentials', + SessionExpired: 'Sorry, your session has expired', /* errors */ CannotConnectOneFlow: 'Cannot connect to OneFlow server', diff --git a/src/fireedge/src/client/hooks/useAuth.js b/src/fireedge/src/client/hooks/useAuth.js index 6e9e9edc8c..7b0d6e40be 100644 --- a/src/fireedge/src/client/hooks/useAuth.js +++ b/src/fireedge/src/client/hooks/useAuth.js @@ -1,7 +1,7 @@ import { useCallback, useEffect } from 'react' import { useSelector, useDispatch, shallowEqual } from 'react-redux' -import { JWT_NAME, FILTER_POOL, ONEADMIN_ID, TIME_HIDE_LOGO } from 'client/constants' +import { T, JWT_NAME, FILTER_POOL, ONEADMIN_ID, TIME_HIDE_LOGO } from 'client/constants' import { storage, findStorageData, removeStoreData, fakeDelay } from 'client/utils' import * as serviceAuth from 'client/services/auth' @@ -84,7 +84,10 @@ const useAuth = () => { .then(() => dispatch(updateSetting)) .then(() => serviceOne.getGroups()) .then(groups => dispatch(setGroups(groups))) - .catch(err => dispatch(failureAuth({ error: err }))) + .catch(() => { + dispatch(logoutRequest()) + dispatch(failureAuth({ error: T.SessionExpired })) + }) }, [dispatch, JWT_NAME, authUser]) const setPrimaryGroup = useCallback(