1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

B #5380: Fix fireedge when session expires (#1189)

(cherry picked from commit d7fe6f7e3d05fb9dd2830ca17e857b3e509a4892)
This commit is contained in:
Sergio Betanzos 2021-05-07 12:44:08 +02:00 committed by Ruben S. Montero
parent 20ab78182a
commit 1bcfd773b1
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
4 changed files with 12 additions and 6 deletions

View File

@ -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)

View File

@ -85,7 +85,7 @@ const Sidebar = memo(({ endpoints }) => {
</Box>
</Drawer>
)
}, (prev, next) => prev.endpoints === next.endpoints)
}, (prev, next) => prev.endpoints.length === next.endpoints.length)
Sidebar.propTypes = {
endpoints: PropTypes.array

View File

@ -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',

View File

@ -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(