mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
(cherry picked from commit 8affcb66a9a99359ba04f8205aba8ef0ab43fc51)
This commit is contained in:
parent
7e068a886a
commit
18bf9dcded
@ -35,26 +35,32 @@ import { JWT_NAME } from 'client/constants'
|
||||
const AuthLayout = ({ subscriptions = [], children }) => {
|
||||
const dispatch = useDispatch()
|
||||
const { changeJwt, stopFirstRender } = useAuthApi()
|
||||
const { jwt, isLogged, isLoginInProgress, firstRender } = useAuth()
|
||||
const { jwt, user, isLogged, isLoginInProgress, firstRender } = useAuth()
|
||||
|
||||
useEffect(() => {
|
||||
if (!jwt) return
|
||||
|
||||
const endpoints = [
|
||||
groupApi.endpoints.getGroups,
|
||||
authApi.endpoints.getAuthUser,
|
||||
...subscriptions,
|
||||
].map((endpoint) =>
|
||||
dispatch(endpoint.initiate(undefined, { forceRefetch: true }))
|
||||
const authSubscription = dispatch(
|
||||
authApi.endpoints.getAuthUser.initiate(undefined, { forceRefetch: true })
|
||||
)
|
||||
|
||||
return authSubscription.unsubscribe
|
||||
}, [dispatch, jwt])
|
||||
|
||||
useEffect(() => {
|
||||
if (!jwt || !user?.NAME) return
|
||||
|
||||
const endpoints = [groupApi.endpoints.getGroups, ...subscriptions].map(
|
||||
(endpoint) =>
|
||||
dispatch(endpoint.initiate(undefined, { forceRefetch: true }))
|
||||
)
|
||||
|
||||
return () => {
|
||||
endpoints.forEach((endpoint) => {
|
||||
endpoint.unsubscribe()
|
||||
endpoint.abort()
|
||||
})
|
||||
}
|
||||
}, [dispatch, jwt])
|
||||
}, [dispatch, jwt, user?.NAME])
|
||||
|
||||
useEffect(() => {
|
||||
if (!jwt) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user